Cjbeery24/mint copy: Invoice checker background tasks (#722)

* #616: Removed blocking call from ledger startup. Instead added it to a background task that repeats every hour.

* make task interval configurable, remember task and cancel it on shutdown

* comments

* add sleep to tests because the background task is async

---------

Co-authored-by: Caleb Beery <cjbeery@gmail.com>
This commit is contained in:
callebtc
2025-04-10 21:25:18 +07:00
committed by GitHub
parent 76e2601efd
commit e1220d2329
3 changed files with 34 additions and 1 deletions

View File

@@ -178,6 +178,9 @@ async def test_startup_fakewallet_pending_quote_success(ledger: Ledger):
# run startup routinge
await ledger.startup_ledger()
# we need to sleep because the startup routine for checking the invoices is async
await asyncio.sleep(1)
# expect that no pending tokens are in db anymore
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
db=ledger.db
@@ -204,6 +207,9 @@ async def test_startup_fakewallet_pending_quote_failure(ledger: Ledger):
# run startup routinge
await ledger.startup_ledger()
# we need to sleep because the startup routine for checking the invoices is async
await asyncio.sleep(1)
# expect that no pending tokens are in db anymore
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
db=ledger.db
@@ -225,6 +231,9 @@ async def test_startup_fakewallet_pending_quote_pending(ledger: Ledger):
# run startup routinge
await ledger.startup_ledger()
# we need to sleep because the startup routine for checking the invoices is async
await asyncio.sleep(1)
# expect that melt quote is still pending
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
db=ledger.db
@@ -247,6 +256,9 @@ async def test_startup_fakewallet_pending_quote_unknown(ledger: Ledger):
# run startup routinge
await ledger.startup_ledger()
# we need to sleep because the startup routine for checking the invoices is async
await asyncio.sleep(1)
# expect that melt quote is still pending
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
db=ledger.db