Browse Source

test_lightningd: Add some more testing for waitinvoice.

ppa-0.6.1
ZmnSCPxj 7 years ago
committed by Christian Decker
parent
commit
6792acf04c
  1. 11
      tests/test_lightningd.py

11
tests/test_lightningd.py

@ -3216,7 +3216,10 @@ class LightningDTests(BaseLightningDTests):
# Create invoices # Create invoices
inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1') inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1')
inv2 = l2.rpc.invoice(1000, 'inv2', 'inv2') 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 # Start waiting on invoice 1, should block
f = self.executor.submit(l2.rpc.waitinvoice, 'inv1') f = self.executor.submit(l2.rpc.waitinvoice, 'inv1')
time.sleep(1) time.sleep(1)
@ -3226,11 +3229,17 @@ class LightningDTests(BaseLightningDTests):
# Waiter should stil be blocked # Waiter should stil be blocked
time.sleep(1) time.sleep(1)
assert not f.done() 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 # Pay invoice 1
l1.rpc.pay(inv1['bolt11']) l1.rpc.pay(inv1['bolt11'])
# Waiter should now finish # Waiter for invoice 1 should now finish
r = f.result(timeout=5) r = f.result(timeout=5)
assert r['label'] == 'inv1' assert r['label'] == 'inv1'
# Waiter for invoice 3 should still be waiting
time.sleep(1)
assert not f3.done()
def test_waitanyinvoice(self): def test_waitanyinvoice(self):
"""Test various variants of waiting for the next invoice to complete. """Test various variants of waiting for the next invoice to complete.

Loading…
Cancel
Save