[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

View File

@@ -1,4 +1,5 @@
import multiprocessing
import os
import shutil
import time
from pathlib import Path
@@ -8,9 +9,13 @@ import pytest_asyncio
import uvicorn
from uvicorn import Config, Server
from cashu.core.db import Database
from cashu.core.migrations import migrate_databases
from cashu.core.settings import settings
from cashu.wallet import migrations
from cashu.lightning.fake import FakeWallet
from cashu.mint import migrations as migrations_mint
from cashu.mint.ledger import Ledger
from cashu.wallet import migrations as migrations_wallet
from cashu.wallet.wallet import Wallet
SERVER_ENDPOINT = "http://localhost:3337"
@@ -61,3 +66,23 @@ def mint():
time.sleep(1)
yield server
server.stop()
@pytest_asyncio.fixture(scope="function")
async def ledger():
async def start_mint_init(ledger):
await migrate_databases(ledger.db, migrations_mint)
await ledger.load_used_proofs()
await ledger.init_keysets()
db_file = "data/mint/test.sqlite3"
if os.path.exists(db_file):
os.remove(db_file)
ledger = Ledger(
db=Database("test", "data/mint"),
seed="TEST_PRIVATE_KEY",
derivation_path="0/0/0/0",
lightning=FakeWallet(),
)
await start_mint_init(ledger)
yield ledger