[Mint] add mint api tests (#189)

* add mint api tests

* add /info test and fix NUT-09 contact info strings

* add test mint api

* replace with requests
This commit is contained in:
calle
2023-05-02 00:43:49 +02:00
committed by GitHub
parent 3c47ab2ac7
commit 61078ce7c8
6 changed files with 78 additions and 35 deletions

44
tests/test_mint_api.py Normal file
View File

@@ -0,0 +1,44 @@
import asyncio
import pytest
import pytest_asyncio
import requests
from cashu.core.settings import settings
from tests.conftest import ledger
BASE_URL = f"http://localhost:3337"
@pytest.mark.asyncio
async def test_info(ledger):
response = requests.get(f"{BASE_URL}/info")
assert response.status_code == 200, f"{response.url} {response.status_code}"
assert response.json()["pubkey"] == ledger.pubkey.serialize().hex()
@pytest.mark.asyncio
async def test_api_keys(ledger):
response = requests.get(f"{BASE_URL}/keys")
assert response.status_code == 200, f"{response.url} {response.status_code}"
assert response.json() == {
str(k): v.serialize().hex() for k, v in ledger.keyset.public_keys.items()
}
@pytest.mark.asyncio
async def test_api_keysets(ledger):
response = requests.get(f"{BASE_URL}/keysets")
assert response.status_code == 200, f"{response.url} {response.status_code}"
assert response.json()["keysets"] == list(ledger.keysets.keysets.keys())
@pytest.mark.asyncio
async def test_api_keyset_keys(ledger):
response = requests.get(
f"{BASE_URL}/keys/{'1cCNIAZ2X/w1'.replace('/', '_').replace('+', '-')}"
)
assert response.status_code == 200, f"{response.url} {response.status_code}"
assert response.json() == {
str(k): v.serialize().hex() for k, v in ledger.keyset.public_keys.items()
}