2022-06-27 00:11:46 +02:00
|
|
|
import pytest
|
|
|
|
|
2024-10-29 09:58:22 +01:00
|
|
|
from lnbits.core.models import Payment
|
|
|
|
|
2022-08-03 14:10:32 +02:00
|
|
|
|
2022-06-27 00:11:46 +02:00
|
|
|
# check if the client is working
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
async def test_core_views_generic(client):
|
|
|
|
response = await client.get("/")
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|
|
|
|
# check GET /public/v1/payment/{payment_hash}: correct hash [should pass]
|
|
|
|
@pytest.mark.asyncio
|
2024-10-29 09:58:22 +01:00
|
|
|
async def test_api_public_payment_longpolling(client, invoice: Payment):
|
|
|
|
response = await client.get(f"/public/v1/payment/{invoice.payment_hash}")
|
2022-06-27 00:11:46 +02:00
|
|
|
assert response.status_code < 300
|
|
|
|
assert response.json()["status"] == "paid"
|
|
|
|
|
|
|
|
|
|
|
|
# check GET /public/v1/payment/{payment_hash}: wrong hash [should fail]
|
|
|
|
@pytest.mark.asyncio
|
2024-10-29 09:58:22 +01:00
|
|
|
async def test_api_public_payment_longpolling_wrong_hash(client, invoice: Payment):
|
|
|
|
response = await client.get(f"/public/v1/payment/{invoice.payment_hash + '0'*64}")
|
2022-06-27 00:11:46 +02:00
|
|
|
assert response.status_code == 404
|
|
|
|
assert response.json()["detail"] == "Payment does not exist."
|