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
46
tests/regtest/test_services_create_invoice.py
Normal file
46
tests/regtest/test_services_create_invoice.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import pytest
|
||||
from bolt11 import decode
|
||||
|
||||
from lnbits.core.services import (
|
||||
PaymentStatus,
|
||||
create_invoice,
|
||||
)
|
||||
from lnbits.wallets import get_funding_source
|
||||
|
||||
description = "test create invoice"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_invoice(from_wallet):
|
||||
payment_hash, pr = await create_invoice(
|
||||
wallet_id=from_wallet.id,
|
||||
amount=1000,
|
||||
memo=description,
|
||||
)
|
||||
invoice = decode(pr)
|
||||
assert invoice.payment_hash == payment_hash
|
||||
assert invoice.amount_msat == 1000000
|
||||
assert invoice.description == description
|
||||
|
||||
funding_source = get_funding_source()
|
||||
status = await funding_source.get_invoice_status(payment_hash)
|
||||
assert isinstance(status, PaymentStatus)
|
||||
assert status.pending
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_internal_invoice(from_wallet):
|
||||
payment_hash, pr = await create_invoice(
|
||||
wallet_id=from_wallet.id, amount=1000, memo=description, internal=True
|
||||
)
|
||||
invoice = decode(pr)
|
||||
assert invoice.payment_hash == payment_hash
|
||||
assert invoice.amount_msat == 1000000
|
||||
assert invoice.description == description
|
||||
|
||||
# Internal invoices are not on fundingsource. so we should get some kind of error
|
||||
# that the invoice is not found, but we get status pending
|
||||
funding_source = get_funding_source()
|
||||
status = await funding_source.get_invoice_status(payment_hash)
|
||||
assert isinstance(status, PaymentStatus)
|
||||
assert status.pending
|
||||
Loading…
Add table
Add a link
Reference in a new issue