test: bleskomat, another try
This commit is contained in:
parent
57b8073eec
commit
5bc2c68cde
2 changed files with 9 additions and 9 deletions
|
|
@ -14,7 +14,6 @@ from lnbits.extensions.bleskomat.helpers import (
|
||||||
query_to_signing_payload,
|
query_to_signing_payload,
|
||||||
)
|
)
|
||||||
from lnbits.extensions.bleskomat.models import CreateBleskomat
|
from lnbits.extensions.bleskomat.models import CreateBleskomat
|
||||||
from lnbits.settings import get_wallet_class
|
|
||||||
|
|
||||||
exchange_rate_providers["dummy"] = {
|
exchange_rate_providers["dummy"] = {
|
||||||
"name": "dummy",
|
"name": "dummy",
|
||||||
|
|
@ -66,7 +65,3 @@ async def lnurl(bleskomat):
|
||||||
"lnurl": lnurl,
|
"lnurl": lnurl,
|
||||||
"secret": secret,
|
"secret": secret,
|
||||||
}
|
}
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
|
||||||
async def WALLET(bleskomat):
|
|
||||||
return get_wallet_class()
|
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ from lnbits.extensions.bleskomat.helpers import (
|
||||||
from lnbits.settings import settings, get_wallet_class
|
from lnbits.settings import settings, get_wallet_class
|
||||||
from tests.conftest import client
|
from tests.conftest import client
|
||||||
|
|
||||||
from tests.extensions.bleskomat.conftest import bleskomat, lnurl, WALLET
|
from tests.extensions.bleskomat.conftest import bleskomat, lnurl
|
||||||
from tests.helpers import credit_wallet, is_regtest
|
from tests.helpers import credit_wallet, is_regtest
|
||||||
|
|
||||||
|
WALLET = get_wallet_class()
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bleskomat_lnurl_api_missing_secret(client):
|
async def test_bleskomat_lnurl_api_missing_secret(client):
|
||||||
|
|
@ -99,7 +99,7 @@ async def test_bleskomat_lnurl_api_valid_signature(client, bleskomat):
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.skipif(is_regtest, reason="this test is only passes in fakewallet")
|
@pytest.mark.skipif(is_regtest, reason="this test is only passes in fakewallet")
|
||||||
async def test_bleskomat_lnurl_api_action_insufficient_balance(client, lnurl, WALLET):
|
async def test_bleskomat_lnurl_api_action_insufficient_balance(client, lnurl):
|
||||||
bleskomat = lnurl["bleskomat"]
|
bleskomat = lnurl["bleskomat"]
|
||||||
secret = lnurl["secret"]
|
secret = lnurl["secret"]
|
||||||
pr = "lntb500n1pseq44upp5xqd38rgad72lnlh4gl339njlrsl3ykep82j6gj4g02dkule7k54qdqqcqzpgxqyz5vqsp5h0zgewuxdxcl2rnlumh6g520t4fr05rgudakpxm789xgjekha75s9qyyssq5vhwsy9knhfeqg0wn6hcnppwmum8fs3g3jxkgw45havgfl6evchjsz3s8e8kr6eyacz02szdhs7v5lg0m7wehd5rpf6yg8480cddjlqpae52xu"
|
pr = "lntb500n1pseq44upp5xqd38rgad72lnlh4gl339njlrsl3ykep82j6gj4g02dkule7k54qdqqcqzpgxqyz5vqsp5h0zgewuxdxcl2rnlumh6g520t4fr05rgudakpxm789xgjekha75s9qyyssq5vhwsy9knhfeqg0wn6hcnppwmum8fs3g3jxkgw45havgfl6evchjsz3s8e8kr6eyacz02szdhs7v5lg0m7wehd5rpf6yg8480cddjlqpae52xu"
|
||||||
|
|
@ -111,15 +111,17 @@ async def test_bleskomat_lnurl_api_action_insufficient_balance(client, lnurl, WA
|
||||||
"fee" in response.json()["reason"]
|
"fee" in response.json()["reason"]
|
||||||
)
|
)
|
||||||
wallet = await get_wallet(bleskomat.wallet)
|
wallet = await get_wallet(bleskomat.wallet)
|
||||||
|
assert wallet, not None
|
||||||
assert wallet.balance_msat == 0
|
assert wallet.balance_msat == 0
|
||||||
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
||||||
|
assert bleskomat_lnurl, not None
|
||||||
assert bleskomat_lnurl.has_uses_remaining() == True
|
assert bleskomat_lnurl.has_uses_remaining() == True
|
||||||
WALLET.pay_invoice.assert_not_called()
|
WALLET.pay_invoice.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.skipif(is_regtest, reason="this test is only passes in fakewallet")
|
@pytest.mark.skipif(is_regtest, reason="this test is only passes in fakewallet")
|
||||||
async def test_bleskomat_lnurl_api_action_success(client, lnurl, WALLET):
|
async def test_bleskomat_lnurl_api_action_success(client, lnurl):
|
||||||
bleskomat = lnurl["bleskomat"]
|
bleskomat = lnurl["bleskomat"]
|
||||||
secret = lnurl["secret"]
|
secret = lnurl["secret"]
|
||||||
pr = "lntb500n1pseq44upp5xqd38rgad72lnlh4gl339njlrsl3ykep82j6gj4g02dkule7k54qdqqcqzpgxqyz5vqsp5h0zgewuxdxcl2rnlumh6g520t4fr05rgudakpxm789xgjekha75s9qyyssq5vhwsy9knhfeqg0wn6hcnppwmum8fs3g3jxkgw45havgfl6evchjsz3s8e8kr6eyacz02szdhs7v5lg0m7wehd5rpf6yg8480cddjlqpae52xu"
|
pr = "lntb500n1pseq44upp5xqd38rgad72lnlh4gl339njlrsl3ykep82j6gj4g02dkule7k54qdqqcqzpgxqyz5vqsp5h0zgewuxdxcl2rnlumh6g520t4fr05rgudakpxm789xgjekha75s9qyyssq5vhwsy9knhfeqg0wn6hcnppwmum8fs3g3jxkgw45havgfl6evchjsz3s8e8kr6eyacz02szdhs7v5lg0m7wehd5rpf6yg8480cddjlqpae52xu"
|
||||||
|
|
@ -128,12 +130,15 @@ async def test_bleskomat_lnurl_api_action_success(client, lnurl, WALLET):
|
||||||
amount=100000,
|
amount=100000,
|
||||||
)
|
)
|
||||||
wallet = await get_wallet(bleskomat.wallet)
|
wallet = await get_wallet(bleskomat.wallet)
|
||||||
|
assert wallet, not None
|
||||||
assert wallet.balance_msat == 100000
|
assert wallet.balance_msat == 100000
|
||||||
WALLET.pay_invoice.reset_mock()
|
WALLET.pay_invoice.reset_mock()
|
||||||
response = await client.get(f"/bleskomat/u?k1={secret}&pr={pr}")
|
response = await client.get(f"/bleskomat/u?k1={secret}&pr={pr}")
|
||||||
assert response.json() == {"status": "OK"}
|
assert response.json() == {"status": "OK"}
|
||||||
wallet = await get_wallet(bleskomat.wallet)
|
wallet = await get_wallet(bleskomat.wallet)
|
||||||
|
assert wallet, not None
|
||||||
assert wallet.balance_msat == 50000
|
assert wallet.balance_msat == 50000
|
||||||
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
bleskomat_lnurl = await get_bleskomat_lnurl(secret)
|
||||||
|
assert bleskomat_lnurl, not None
|
||||||
assert bleskomat_lnurl.has_uses_remaining() == False
|
assert bleskomat_lnurl.has_uses_remaining() == False
|
||||||
WALLET.pay_invoice.assert_called_once_with(pr, 2000)
|
WALLET.pay_invoice.assert_called_once_with(pr, 2000)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue