From 0925e404d6a30236a30af39135e95170e2be7756 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Tue, 23 Jan 2018 12:36:41 +0000 Subject: [PATCH] test_lightningd.py: Test new expiration system in more detail. --- tests/test_lightningd.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 2cd03721b..a189ababd 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -401,6 +401,30 @@ class LightningDTests(BaseLightningDTests): 'Unknown invoice', l2.rpc.delinvoice, 'test_pay', 'expired') + + # Test expiration waiting. + # The second invoice created expires first. + l2.rpc.invoice('any', 'inv1', 'description', 5) + l2.rpc.invoice('any', 'inv2', 'description', 2) + l2.rpc.invoice('any', 'inv3', 'description', 8) + # Check waitinvoice correctly waits + w1 = self.executor.submit(l2.rpc.waitinvoice, 'inv1') + w2 = self.executor.submit(l2.rpc.waitinvoice, 'inv2') + w3 = self.executor.submit(l2.rpc.waitinvoice, 'inv3') + time.sleep(1) # total 1 + assert not w1.done() + assert not w2.done() + assert not w3.done() + time.sleep(2) # total 3 + assert not w1.done() + self.assertRaises(ValueError, w2.result) + assert not w3.done() + time.sleep(3) # total 6 + self.assertRaises(ValueError, w1.result) + assert not w3.done() + time.sleep(4) # total 10 + self.assertRaises(ValueError, w3.result) + def test_connect(self): l1,l2 = self.connect()