BUG: proper exception for already paid internal invoices (#1593)

* BUG: proper exception for paid interal invoices

* test should now fail, because we pay invoice twice, and should also work in regtest

* sorting

* unpack check_internal

* introduce another crud fn for checking internal paid payment

* rename

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
dni ⚡ 2023-04-03 14:44:17 +02:00 committed by GitHub
parent a9bdf24425
commit fe9e821af5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View file

@ -6,7 +6,7 @@ from lnbits import bolt11
from lnbits.core.views.api import api_payment
from lnbits.settings import get_wallet_class
from ...helpers import get_random_invoice_data, is_fake, is_regtest
from ...helpers import get_random_invoice_data, is_fake
WALLET = get_wallet_class()
@ -170,16 +170,15 @@ async def test_pay_invoice_invoicekey(client, invoice, inkey_headers_from):
assert response.status_code >= 300 # should fail
# check POST /api/v1/payments: payment with admin key [should pass]
# check POST /api/v1/payments: payment with admin key, trying to pay twice [should fail]
@pytest.mark.asyncio
@pytest.mark.skipif(is_regtest, reason="this only works in fakewallet")
async def test_pay_invoice_adminkey(client, invoice, adminkey_headers_from):
data = {"out": True, "bolt11": invoice["payment_request"]}
# try payment with admin key
response = await client.post(
"/api/v1/payments", json=data, headers=adminkey_headers_from
)
assert response.status_code < 300 # should pass
assert response.status_code > 300 # should fail
# check POST /api/v1/payments/decode