mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-19 09:54:21 +01:00
1e752dc3d2
* test: services create and pay invoice * add more tests * check with fundingsource * check status
46 lines
1.1 KiB
Python
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,
|
|
)
|