feat: block pay invoice (#2727)
This commit is contained in:
parent
e85a78854e
commit
a58deff70c
7 changed files with 61 additions and 14 deletions
36
tests/unit/test_services_wallet_limit.py
Normal file
36
tests/unit/test_services_wallet_limit.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
|
||||
from lnbits.core.services import check_wallet_daily_withdraw_limit
|
||||
from lnbits.settings import settings
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_no_wallet_limit():
|
||||
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."
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_wallet_limit_but_no_payments():
|
||||
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."
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_no_wallet_spend_allowed():
|
||||
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
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue