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

Function test_invoice_payment_hook

tests/test_plugin.py:689–710  ·  view source on GitHub ↗

l1 uses the reject-payment plugin to reject invoices with odd preimages.

(node_factory)

Source from the content-addressed store, hash-verified

687
688
689def test_invoice_payment_hook(node_factory):
690 """ l1 uses the reject-payment plugin to reject invoices with odd preimages.
691 """
692 opts = [{}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/reject_some_invoices.py')}]
693 l1, l2 = node_factory.line_graph(2, opts=opts)
694
695 # This one works
696 inv1 = l2.rpc.invoice(1230, 'label', 'description', preimage='1' * 64)
697 l1.rpc.xpay(inv1['bolt11'])
698
699 l2.daemon.wait_for_log('label=label')
700 l2.daemon.wait_for_log('msat=')
701 l2.daemon.wait_for_log('preimage=' + '1' * 64)
702
703 # This one will be rejected.
704 inv2 = l2.rpc.invoice(1230, 'label2', 'description', preimage='0' * 64)
705 with pytest.raises(RpcError, match=r'Unexpected error \(temporary_node_failure\) from final node'):
706 l1.rpc.xpay(inv2['bolt11'])
707
708 l2.daemon.wait_for_log('label=label2')
709 l2.daemon.wait_for_log('msat=')
710 l2.daemon.wait_for_log('preimage=' + '0' * 64)
711
712
713def test_invoice_payment_hook_hold(node_factory, executor):

Callers

nothing calls this directly

Calls 5

joinMethod · 0.80
line_graphMethod · 0.80
wait_for_logMethod · 0.80
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected