diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 8a906e696..45c6f807d 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -425,6 +425,7 @@ class LightningDTests(BaseLightningDTests): def test_autocleaninvoice(self): l1 = self.node_factory.get_node() + start_time = time.time() l1.rpc.autocleaninvoice(cycle_seconds=8, expired_by=2) 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('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. # inv1 should be expired assert len(l1.rpc.listinvoices('inv1')['invoices']) == 1 @@ -443,19 +444,19 @@ class LightningDTests(BaseLightningDTests): assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1 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. assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0 assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1 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 assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0 assert len(l1.rpc.listinvoices('inv2')['invoices']) == 1 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 assert len(l1.rpc.listinvoices('inv1')['invoices']) == 0 assert len(l1.rpc.listinvoices('inv2')['invoices']) == 0