mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
pytest: fix autoclean test flake
``` l3.rpc.setconfig('autoclean-cycle', 10) # First it expires. > wait_for(lambda: only_one(l3.rpc.listinvoices('inv1')['invoices'])['status'] == 'expired') ``` If we're slow enough, the invoice is cleaned before we see it expire! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
763ec6ad43
commit
dec8ad3b8d
1 changed files with 16 additions and 4 deletions
|
@ -3191,10 +3191,22 @@ def test_autoclean(node_factory):
|
|||
|
||||
l3.rpc.setconfig('autoclean-cycle', 10)
|
||||
|
||||
# First it expires.
|
||||
wait_for(lambda: only_one(l3.rpc.listinvoices('inv1')['invoices'])['status'] == 'expired')
|
||||
# Now will get autocleaned
|
||||
wait_for(lambda: l3.rpc.listinvoices('inv1')['invoices'] == [])
|
||||
# It will always go unpaid->expired->deleted, but we might miss it!
|
||||
was_expired = False
|
||||
while True:
|
||||
# Is it deleted yet?
|
||||
invs = l3.rpc.listinvoices('inv1')['invoices']
|
||||
if invs == []:
|
||||
break
|
||||
if was_expired:
|
||||
assert only_one(invs)['status'] == 'expired'
|
||||
else:
|
||||
if only_one(invs)['status'] == 'expired':
|
||||
was_expired = True
|
||||
else:
|
||||
assert only_one(invs)['status'] == 'unpaid'
|
||||
time.sleep(1)
|
||||
|
||||
assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['cleaned'] == 1
|
||||
|
||||
# Keeps settings across restarts
|
||||
|
|
Loading…
Add table
Reference in a new issue