mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 10:34:20 +01:00
Mint: table locks (#566)
* clean up db * db: table lock * db.table_with_schema * fix encrypt.py * postgres nowait * add timeout to lock * melt quote state in db * kinda working * kinda working with postgres * remove dispose * getting there * porperly clean up db for tests * faster tests * configure connection pooling * try github with connection pool * invoice dispatcher does not lock db * fakewallet: pay_if_regtest waits * pay fakewallet invoices * add more * faster * slower * pay_if_regtest async * do not lock the invoice dispatcher * test: do I get disk I/O errors if we disable the invoice_callback_dispatcher? * fix fake so it workss without a callback dispatchert * test on github * readd tasks * refactor * increase time for lock invoice disatcher * try avoiding a race * remove task * github actions: test regtest with postgres * mint per module * no connection pool for testing * enable pool * do not resend paid event * reuse connection * close db connections * sessions * enable debug * dispose engine * disable connection pool for tests * enable connection pool for postgres only * clean up shutdown routine * remove wait for lightning fakewallet lightning invoice * cancel invoice listener tasks on shutdown * fakewallet conftest: decrease outgoing delay * delay payment and set postgres only if needed * disable fail fast for regtest * clean up regtest.yml * change order of tests_db.py * row-specific mint_quote locking * refactor * fix lock statement * refactor swap * refactor * remove psycopg2 * add connection string example to .env.example * remove unnecessary pay * shorter sleep in test_wallet_subscription_swap
This commit is contained in:
@@ -22,7 +22,8 @@ from cashu.mint.ledger import Ledger
|
||||
SERVER_PORT = 3337
|
||||
SERVER_ENDPOINT = f"http://localhost:{SERVER_PORT}"
|
||||
|
||||
settings.debug = False
|
||||
settings.debug = True
|
||||
settings.log_level = "TRACE"
|
||||
settings.cashu_dir = "./test_data/"
|
||||
settings.mint_host = "localhost"
|
||||
settings.mint_port = SERVER_PORT
|
||||
@@ -49,6 +50,7 @@ settings.mint_transaction_rate_limit_per_minute = 60
|
||||
settings.mint_lnd_enable_mpp = True
|
||||
settings.mint_clnrest_enable_mpp = False
|
||||
settings.mint_input_fee_ppk = 0
|
||||
settings.db_connection_pool = True
|
||||
|
||||
assert "test" in settings.cashu_dir
|
||||
shutil.rmtree(settings.cashu_dir, ignore_errors=True)
|
||||
@@ -83,11 +85,6 @@ class UvicornServer(multiprocessing.Process):
|
||||
async def ledger():
|
||||
async def start_mint_init(ledger: Ledger) -> Ledger:
|
||||
await migrate_databases(ledger.db, migrations_mint)
|
||||
# add a new keyset (with a new ID) which will be duplicated with a keyset with an
|
||||
# old ID by mint migration m018_duplicate_deprecated_keyset_ids
|
||||
# await ledger.activate_keyset(derivation_path=settings.mint_derivation_path, version="0.15.0")
|
||||
# await migrations_mint.m018_duplicate_deprecated_keyset_ids(ledger.db)
|
||||
|
||||
ledger = Ledger(
|
||||
db=Database("mint", settings.mint_database),
|
||||
seed=settings.mint_private_key,
|
||||
@@ -107,8 +104,10 @@ async def ledger():
|
||||
# clear postgres database
|
||||
db = Database("mint", settings.mint_database)
|
||||
async with db.connect() as conn:
|
||||
# drop all tables
|
||||
await conn.execute("DROP SCHEMA public CASCADE;")
|
||||
await conn.execute("CREATE SCHEMA public;")
|
||||
await db.engine.dispose()
|
||||
|
||||
wallets_module = importlib.import_module("cashu.lightning")
|
||||
lightning_backend = getattr(wallets_module, settings.mint_backend_bolt11_sat)()
|
||||
@@ -125,6 +124,7 @@ async def ledger():
|
||||
ledger = await start_mint_init(ledger)
|
||||
yield ledger
|
||||
print("teardown")
|
||||
await ledger.shutdown_ledger()
|
||||
|
||||
|
||||
# # This fixture is used for tests that require API access to the mint
|
||||
@@ -134,6 +134,7 @@ def mint():
|
||||
"cashu.mint.app:app",
|
||||
port=settings.mint_listen_port,
|
||||
host=settings.mint_listen_host,
|
||||
log_level="trace",
|
||||
)
|
||||
|
||||
server = UvicornServer(config=config)
|
||||
|
||||
Reference in New Issue
Block a user