2024-10-01 17:17:42 +03:00
|
|
|
import pytest
|
|
|
|
|
2024-10-29 09:58:22 +01:00
|
|
|
from lnbits.core.services.payments import check_wallet_daily_withdraw_limit
|
|
|
|
from lnbits.settings import Settings
|
2024-10-01 17:17:42 +03:00
|
|
|
|
|
|
|
|
2024-12-11 10:39:28 +01:00
|
|
|
@pytest.mark.anyio
|
2024-10-29 09:58:22 +01:00
|
|
|
async def test_no_wallet_limit(settings: Settings):
|
2024-10-01 17:17:42 +03:00
|
|
|
settings.lnbits_wallet_limit_daily_max_withdraw = 0
|
|
|
|
result = await check_wallet_daily_withdraw_limit(
|
|
|
|
conn=None, wallet_id="333333", amount_msat=0
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result is None, "No limit set."
|
|
|
|
|
|
|
|
|
2024-12-11 10:39:28 +01:00
|
|
|
@pytest.mark.anyio
|
2024-10-29 09:58:22 +01:00
|
|
|
async def test_wallet_limit_but_no_payments(settings: Settings):
|
2024-10-01 17:17:42 +03:00
|
|
|
settings.lnbits_wallet_limit_daily_max_withdraw = 5
|
|
|
|
result = await check_wallet_daily_withdraw_limit(
|
|
|
|
conn=None, wallet_id="333333", amount_msat=0
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result is None, "Limit not reqached."
|
|
|
|
|
|
|
|
|
2024-12-11 10:39:28 +01:00
|
|
|
@pytest.mark.anyio
|
2024-10-29 09:58:22 +01:00
|
|
|
async def test_no_wallet_spend_allowed(settings: Settings):
|
2024-10-01 17:17:42 +03:00
|
|
|
settings.lnbits_wallet_limit_daily_max_withdraw = -1
|
|
|
|
|
|
|
|
with pytest.raises(
|
|
|
|
ValueError, match="It is not allowed to spend funds from this server."
|
|
|
|
):
|
|
|
|
await check_wallet_daily_withdraw_limit(
|
|
|
|
conn=None, wallet_id="333333", amount_msat=0
|
|
|
|
)
|