TEST: add hold invoices to test helpers and a basic test (#1838)
* add hold invoices and basic test * run request in parallel * create_task * dont cancel it --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,12 @@ from lnbits.db import DB_TYPE, SQLITE
|
||||
from lnbits.wallets import get_wallet_class
|
||||
from tests.conftest import CreateInvoiceData, api_payments_create_invoice
|
||||
|
||||
from ...helpers import get_random_invoice_data, is_fake, pay_real_invoice
|
||||
from ...helpers import (
|
||||
get_random_invoice_data,
|
||||
is_fake,
|
||||
pay_real_invoice,
|
||||
settle_invoice,
|
||||
)
|
||||
|
||||
WALLET = get_wallet_class()
|
||||
|
||||
@@ -459,6 +464,30 @@ async def test_pay_real_invoice_set_pending_and_check_state(
|
||||
assert payment_not_pending.pending is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_pay_hold_invoice(client, hold_invoice, adminkey_headers_from):
|
||||
preimage, invoice = hold_invoice
|
||||
task = asyncio.create_task(
|
||||
client.post(
|
||||
"/api/v1/payments",
|
||||
json={"bolt11": invoice["payment_request"]},
|
||||
headers=adminkey_headers_from,
|
||||
)
|
||||
)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
# TODO: Proper test calle :)
|
||||
# settle hold invoice
|
||||
settle_invoice(preimage)
|
||||
|
||||
response = await task
|
||||
assert response.status_code < 300
|
||||
# check if paid
|
||||
# randomly cancel invoice
|
||||
# cancel_invoice(invoice["payment_hash"])
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.skipif(is_fake, reason="this only works in regtest")
|
||||
async def test_receive_real_invoice_set_pending_and_check_state(
|
||||
|
||||
Reference in New Issue
Block a user