pytest: Stabilize test_autocleaninvoice
The RPC calls aren't really free, so let's wait for absolute times, computed from the `start_time` instead. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
e117d25c1f
commit
a35cc9a79f
|
@ -425,6 +425,7 @@ class LightningDTests(BaseLightningDTests):
|
||||||
def test_autocleaninvoice(self):
|
def test_autocleaninvoice(self):
|
||||||
l1 = self.node_factory.get_node()
|
l1 = self.node_factory.get_node()
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2)
|
l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2)
|
||||||
|
|
||||||
l1.rpc.invoice(msatoshi=12300, label='inv1', description='1', expiry=4)
|
l1.rpc.invoice(msatoshi=12300, label='inv1', description='1', expiry=4)
|
||||||
|
@ -435,7 +436,7 @@ class LightningDTests(BaseLightningDTests):
|
||||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
|
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
|
||||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||||
|
|
||||||
time.sleep(6) # total 6
|
time.sleep(start_time - time.time() + 6) # total 6
|
||||||
# Both should still be there - auto clean cycle not started.
|
# Both should still be there - auto clean cycle not started.
|
||||||
# inv1 should be expired
|
# inv1 should be expired
|
||||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
|
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1
|
||||||
|
@ -443,19 +444,19 @@ class LightningDTests(BaseLightningDTests):
|
||||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||||
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] != 'expired'
|
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] != 'expired'
|
||||||
|
|
||||||
time.sleep(4) # total 10
|
time.sleep(start_time - time.time() + 10) # total 10
|
||||||
# inv1 should have deleted, inv2 still there and unexpired.
|
# inv1 should have deleted, inv2 still there and unexpired.
|
||||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
||||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||||
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] != 'expired'
|
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] != 'expired'
|
||||||
|
|
||||||
time.sleep(4) # total 14
|
time.sleep(start_time - time.time() + 14) # total 14
|
||||||
# inv2 should still be there, but expired
|
# inv2 should still be there, but expired
|
||||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
||||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1
|
||||||
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] == 'expired'
|
assert l1.rpc.listinvoices('inv2')['invoices'][0]['status'] == 'expired'
|
||||||
|
|
||||||
time.sleep(4) # total 18
|
time.sleep(start_time - time.time() + 18) # total 18
|
||||||
# Everything deleted
|
# Everything deleted
|
||||||
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0
|
||||||
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 0
|
assert len(l1.rpc.listinvoices('inv2')['invoices']) == 0
|
||||||
|
|
Loading…
Reference in New Issue