test: services create and pay invoice (#2452)
* test: services create and pay invoice * add more tests * check with fundingsource * check status
This commit is contained in:
parent
6730c6ed67
commit
1e752dc3d2
3 changed files with 98 additions and 0 deletions
45
tests/regtest/test_services_pay_invoice.py
Normal file
45
tests/regtest/test_services_pay_invoice.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import pytest
|
||||
|
||||
from lnbits.core.crud import (
|
||||
get_standalone_payment,
|
||||
)
|
||||
from lnbits.core.services import (
|
||||
PaymentError,
|
||||
pay_invoice,
|
||||
)
|
||||
|
||||
description = "test pay invoice"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_services_pay_invoice(to_wallet, real_invoice):
|
||||
payment_hash = await pay_invoice(
|
||||
wallet_id=to_wallet.id,
|
||||
payment_request=real_invoice.get("bolt11"),
|
||||
description=description,
|
||||
)
|
||||
assert payment_hash
|
||||
payment = await get_standalone_payment(payment_hash)
|
||||
assert payment
|
||||
assert not payment.pending
|
||||
assert payment.memo == description
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_services_pay_invoice_invalid_bolt11(to_wallet):
|
||||
with pytest.raises(PaymentError):
|
||||
await pay_invoice(
|
||||
wallet_id=to_wallet.id,
|
||||
payment_request="lnbcr1123123n",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_services_pay_invoice_0_amount_invoice(
|
||||
to_wallet, real_amountless_invoice
|
||||
):
|
||||
with pytest.raises(PaymentError):
|
||||
await pay_invoice(
|
||||
wallet_id=to_wallet.id,
|
||||
payment_request=real_amountless_invoice,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue