From 6792acf04c5f5c3c0040a9b12fec953c79f12484 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Tue, 20 Feb 2018 14:06:51 +0000 Subject: [PATCH] test_lightningd: Add some more testing for waitinvoice. --- tests/test_lightningd.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index d09f2af6e..dcc3bfcd6 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -3216,7 +3216,10 @@ class LightningDTests(BaseLightningDTests): # Create invoices inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1') inv2 = l2.rpc.invoice(1000, 'inv2', 'inv2') + inv3 = l2.rpc.invoice(1000, 'inv3', 'inv3') + # Start waiting on invoice 3 + f3 = self.executor.submit(l2.rpc.waitinvoice, 'inv3') # Start waiting on invoice 1, should block f = self.executor.submit(l2.rpc.waitinvoice, 'inv1') time.sleep(1) @@ -3226,11 +3229,17 @@ class LightningDTests(BaseLightningDTests): # Waiter should stil be blocked time.sleep(1) assert not f.done() + # Waiting on invoice 2 should return immediately + r = self.executor.submit(l2.rpc.waitinvoice, 'inv2').result(timeout=5) + assert r['label'] == 'inv2' # Pay invoice 1 l1.rpc.pay(inv1['bolt11']) - # Waiter should now finish + # Waiter for invoice 1 should now finish r = f.result(timeout=5) assert r['label'] == 'inv1' + # Waiter for invoice 3 should still be waiting + time.sleep(1) + assert not f3.done() def test_waitanyinvoice(self): """Test various variants of waiting for the next invoice to complete.