mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-23 19:54:18 +01:00
Testing: check if pipeline gets stuck because of startup task (#745)
* lets check if this gets stuck with postgres or not * check if it works if I add sleeps * replace startup_ledger with await ledger._check_pending_proofs_and_melt_quotes() in tests * fix typo to trigger tests again
This commit is contained in:
@@ -66,7 +66,13 @@ from .tasks import LedgerTasks
|
|||||||
from .verification import LedgerVerification
|
from .verification import LedgerVerification
|
||||||
|
|
||||||
|
|
||||||
class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerTasks, LedgerFeatures, LedgerKeysets):
|
class Ledger(
|
||||||
|
LedgerVerification,
|
||||||
|
LedgerSpendingConditions,
|
||||||
|
LedgerTasks,
|
||||||
|
LedgerFeatures,
|
||||||
|
LedgerKeysets,
|
||||||
|
):
|
||||||
backends: Mapping[Method, Mapping[Unit, LightningBackend]] = {}
|
backends: Mapping[Method, Mapping[Unit, LightningBackend]] = {}
|
||||||
keysets: Dict[str, MintKeyset] = {}
|
keysets: Dict[str, MintKeyset] = {}
|
||||||
events = LedgerEventManager()
|
events = LedgerEventManager()
|
||||||
|
|||||||
@@ -176,11 +176,8 @@ async def test_startup_fakewallet_pending_quote_success(ledger: Ledger):
|
|||||||
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
||||||
assert states[0].pending
|
assert states[0].pending
|
||||||
settings.fakewallet_payment_state = PaymentResult.SETTLED.name
|
settings.fakewallet_payment_state = PaymentResult.SETTLED.name
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# 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
|
# expect that no pending tokens are in db anymore
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -205,11 +202,8 @@ async def test_startup_fakewallet_pending_quote_failure(ledger: Ledger):
|
|||||||
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
||||||
assert states[0].pending
|
assert states[0].pending
|
||||||
settings.fakewallet_payment_state = PaymentResult.FAILED.name
|
settings.fakewallet_payment_state = PaymentResult.FAILED.name
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# 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
|
# expect that no pending tokens are in db anymore
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -229,11 +223,8 @@ async def test_startup_fakewallet_pending_quote_pending(ledger: Ledger):
|
|||||||
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
||||||
assert states[0].pending
|
assert states[0].pending
|
||||||
settings.fakewallet_payment_state = PaymentResult.PENDING.name
|
settings.fakewallet_payment_state = PaymentResult.PENDING.name
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# 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
|
# expect that melt quote is still pending
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -254,11 +245,8 @@ async def test_startup_fakewallet_pending_quote_unknown(ledger: Ledger):
|
|||||||
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
states = await ledger.db_read.get_proofs_states([pending_proof.Y])
|
||||||
assert states[0].pending
|
assert states[0].pending
|
||||||
settings.fakewallet_payment_state = PaymentResult.UNKNOWN.name
|
settings.fakewallet_payment_state = PaymentResult.UNKNOWN.name
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# 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
|
# expect that melt quote is still pending
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -299,8 +287,8 @@ async def test_startup_regtest_pending_quote_pending(wallet: Wallet, ledger: Led
|
|||||||
)
|
)
|
||||||
await asyncio.sleep(SLEEP_TIME)
|
await asyncio.sleep(SLEEP_TIME)
|
||||||
|
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# expect that melt quote is still pending
|
# expect that melt quote is still pending
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -349,8 +337,8 @@ async def test_startup_regtest_pending_quote_success(wallet: Wallet, ledger: Led
|
|||||||
settle_invoice(preimage=preimage)
|
settle_invoice(preimage=preimage)
|
||||||
await asyncio.sleep(SLEEP_TIME)
|
await asyncio.sleep(SLEEP_TIME)
|
||||||
|
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# expect that no melt quote is pending
|
# expect that no melt quote is pending
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -400,8 +388,8 @@ async def test_startup_regtest_pending_quote_failure(wallet: Wallet, ledger: Led
|
|||||||
cancel_invoice(preimage_hash=preimage_hash)
|
cancel_invoice(preimage_hash=preimage_hash)
|
||||||
await asyncio.sleep(SLEEP_TIME)
|
await asyncio.sleep(SLEEP_TIME)
|
||||||
|
|
||||||
# run startup routinge
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# expect that no melt quote is pending
|
# expect that no melt quote is pending
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -466,7 +454,7 @@ async def test_startup_regtest_pending_quote_unknown(wallet: Wallet, ledger: Led
|
|||||||
await asyncio.sleep(SLEEP_TIME)
|
await asyncio.sleep(SLEEP_TIME)
|
||||||
|
|
||||||
# run startup routine
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
# expect that melt quote is still pending
|
# expect that melt quote is still pending
|
||||||
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
melt_quotes = await ledger.crud.get_all_melt_quotes_from_pending_proofs(
|
||||||
@@ -511,7 +499,7 @@ async def test_regtest_check_nonexisting_melt_quote(wallet: Wallet, ledger: Ledg
|
|||||||
assert melt_quotes.state == MeltQuoteState.pending
|
assert melt_quotes.state == MeltQuoteState.pending
|
||||||
|
|
||||||
# run startup routine
|
# run startup routine
|
||||||
await ledger.startup_ledger()
|
await ledger._check_pending_proofs_and_melt_quotes()
|
||||||
|
|
||||||
status: PaymentStatus = await ledger.backends[Method.bolt11][
|
status: PaymentStatus = await ledger.backends[Method.bolt11][
|
||||||
Unit.sat
|
Unit.sat
|
||||||
|
|||||||
Reference in New Issue
Block a user