MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_waitinvoice

Function test_waitinvoice

tests/test_invoices.py:469–501  ·  view source on GitHub ↗

Test waiting for one invoice will not return if another invoice is paid.

(node_factory, executor)

Source from the content-addressed store, hash-verified

467
468
469def test_waitinvoice(node_factory, executor):
470 """Test waiting for one invoice will not return if another invoice is paid.
471 """
472 # Setup
473 l1, l2 = node_factory.line_graph(2)
474
475 # Create invoices
476 inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1')
477 inv2 = l2.rpc.invoice(1000, 'inv2', 'inv2')
478 l2.rpc.invoice(1000, 'inv3', 'inv3')
479
480 # Start waiting on invoice 3
481 f3 = executor.submit(l2.rpc.waitinvoice, 'inv3')
482 # Start waiting on invoice 1, should block
483 f = executor.submit(l2.rpc.waitinvoice, 'inv1')
484 time.sleep(1)
485 assert not f.done()
486 # Pay invoice 2
487 l1.rpc.xpay(inv2['bolt11'])
488 # Waiter should stil be blocked
489 time.sleep(1)
490 assert not f.done()
491 # Waiting on invoice 2 should return immediately
492 r = executor.submit(l2.rpc.waitinvoice, 'inv2').result(timeout=5)
493 assert r['label'] == 'inv2'
494 # Pay invoice 1
495 l1.rpc.xpay(inv1['bolt11'])
496 # Waiter for invoice 1 should now finish
497 r = f.result(timeout=5)
498 assert r['label'] == 'inv1'
499 # Waiter for invoice 3 should still be waiting
500 time.sleep(1)
501 assert not f3.done()
502
503
504def test_waitanyinvoice(node_factory, executor):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected