Files
lnbits/tests/regtest/test_services_pay_invoice.py
T
dni ⚡ deee7d80be refactor services
- add PaymentFiatAmount
- return Payment on api endpoints
2024-10-17 10:43:03 +02:00

33 lines
775 B
Python

import pytest
from lnbits.core.services import (
PaymentError,
PaymentState,
pay_invoice,
)
description = "test pay invoice"
@pytest.mark.asyncio
async def test_services_pay_invoice(to_wallet, real_invoice):
payment = await pay_invoice(
wallet_id=to_wallet.id,
payment_request=real_invoice.get("bolt11"),
description=description,
)
assert payment
assert not payment.status == PaymentState.SUCCESS
assert payment.memo == description
@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,
)