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

Function test_htlc_accepted_hook_customtlvs

tests/test_plugin.py:2846–2866  ·  view source on GitHub ↗

Passes an custom extra tlv field to the hooks return that should be set as the `update_add_htlc_tlvs` in the `update_add_htlc` message on forwards.

(node_factory)

Source from the content-addressed store, hash-verified

2844
2845
2846def test_htlc_accepted_hook_customtlvs(node_factory):
2847 """ Passes an custom extra tlv field to the hooks return that should be set
2848 as the `update_add_htlc_tlvs` in the `update_add_htlc` message on
2849 forwards.
2850 """
2851 plugin = os.path.join(os.path.dirname(__file__), 'plugins/htlc_accepted-customtlv.py')
2852 l1, l2, l3 = node_factory.line_graph(3, opts=[{}, {'plugin': plugin}, {'plugin': plugin}], wait_for_announce=True)
2853
2854 # Single tlv - Check that we receive the extra tlv at l3 attached by l2.
2855 single_tlv = "fe00010001012a" # represents type: 65537, lenght: 1, value: 42
2856 l2.rpc.setcustomtlvs(tlvs=single_tlv)
2857 inv = l3.rpc.invoice(1000, 'customtlvs-singletlv', '')['bolt11']
2858 l1.rpc.xpay(inv)
2859 l3.daemon.wait_for_log(f"called htlc accepted hook with extra_tlvs: {single_tlv}")
2860
2861 # Mutliple tlvs - Check that we recieve multiple extra tlvs at l3 attached by l2.
2862 multi_tlv = "fdffff012afe00010001020539" # represents type: 65535, length: 1, value: 42 and type: 65537, length: 2, value: 1337
2863 l2.rpc.setcustomtlvs(tlvs=multi_tlv)
2864 inv = l3.rpc.invoice(1000, 'customtlvs-multitlvs', '')['bolt11']
2865 l1.rpc.xpay(inv)
2866 l3.daemon.wait_for_log(f"called htlc accepted hook with extra_tlvs: {multi_tlv}")
2867
2868
2869def test_htlc_accepted_hook_malformedtlvs(node_factory):

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