* return error for wrong key * payment check use key dependency * more expressive error * re-add optional key * more tests * more * more granular * more testing * custom event_loop * tests work * fix lots of mypy errors * test_public_api * both files * remove unused import * tests * tests working * rm empty file * minimal test * set FAKE_WALLET_SECRET="ToTheMoon1" * set FAKE_WALLET_SECRET="ToTheMoon1" * trial and error * trial and error * test postgres * test postgres * test postgres * test postgres * test postgres * test postgres * test build * skip mypy
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import pytest
|
|
from lnbits.core.crud import get_wallet
|
|
|
|
# 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
|
|
async def test_api_public_payment_longpolling(client, invoice):
|
|
response = await client.get(f"/public/v1/payment/{invoice['payment_hash']}")
|
|
assert response.status_code < 300
|
|
assert response.json()["status"] == "paid"
|
|
|
|
|
|
# check GET /public/v1/payment/{payment_hash}: wrong hash [should fail]
|
|
@pytest.mark.asyncio
|
|
async def test_api_public_payment_longpolling_wrong_hash(client, invoice):
|
|
response = await client.get(
|
|
f"/public/v1/payment/{invoice['payment_hash'] + '0'*64}"
|
|
)
|
|
assert response.status_code == 404
|
|
assert response.json()["detail"] == "Payment does not exist."
|
|
|
|
|
|
# check GET /.well-known/lnurlp/{username}: wrong username [should fail]
|
|
@pytest.mark.asyncio
|
|
async def test_lnaddress_wrong_hash(client):
|
|
username = "wrong_name"
|
|
response = await client.get(f"/.well-known/lnurlp/{username}")
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "ERROR"
|
|
assert response.json()["reason"] == "Address not found."
|