lnbits-legend/tests/regtest/test_services_pay_invoice.py
dni ⚡ 1e752dc3d2
test: services create and pay invoice (#2452)
* test: services create and pay invoice
* add more tests
* check with fundingsource
* check status
2024-05-13 16:55:38 +02:00

46 lines
1.1 KiB
Python

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,
)