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

Function test_injectpaymentonion_peerfail

tests/test_pay.py:6856–6896  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

6854
6855
6856def test_injectpaymentonion_peerfail(node_factory, executor):
6857 l1, l2 = node_factory.line_graph(2,
6858 opts=[{'may_reconnect': True,
6859 'dev-no-reconnect': None,
6860 'disconnect': ['=WIRE_UPDATE_ADD_HTLC', '-WIRE_COMMITMENT_SIGNED']},
6861 {'may_reconnect': True,
6862 'dev-no-reconnect': None}])
6863 blockheight = l1.rpc.getinfo()['blockheight']
6864
6865 inv1 = l2.rpc.invoice(1000, "test_injectpaymentonion_peerfail", "test_injectpaymentonion_peerfail")
6866
6867 # First hop for injectpaymentonion is self.
6868 hops = [{'pubkey': l1.info['id'],
6869 'payload': serialize_payload_tlv(1000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6870 {'pubkey': l2.info['id'],
6871 'payload': serialize_payload_final_tlv(1000, 18, 1000, blockheight, inv1['payment_secret']).hex()}]
6872 onion = l1.rpc.createonion(hops=hops, assocdata=inv1['payment_hash'])
6873
6874 l1.rpc.disconnect(l2.info['id'], force=True)
6875 with pytest.raises(RpcError, match='WIRE_TEMPORARY_CHANNEL_FAILURE'):
6876 l1.rpc.injectpaymentonion(onion=onion['onion'],
6877 payment_hash=inv1['payment_hash'],
6878 amount_msat=1000,
6879 cltv_expiry=blockheight + 18 + 6,
6880 partid=1,
6881 groupid=0)
6882 # In fact, it won't create any sendpays entry, since it fails too early.
6883 assert l1.rpc.listsendpays() == {'payments': []}
6884
6885 # This will hang, since we disconnect once committed. But provides another
6886 # (legitimately) pending payment for our migration code to test.
6887 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
6888 executor.submit(l1.rpc.injectpaymentonion,
6889 onion=onion['onion'],
6890 payment_hash=inv1['payment_hash'],
6891 amount_msat=1000,
6892 cltv_expiry=blockheight + 18 + 6,
6893 partid=2,
6894 groupid=0)
6895 l1.daemon.wait_for_log("dev_disconnect: =WIRE_UPDATE_ADD_HTLC")
6896 assert [p['status'] for p in l1.rpc.listsendpays()['payments']] == ['pending']
6897
6898
6899def test_parallel_channels_reserve(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 10

serialize_payload_tlvFunction · 0.90
first_scidFunction · 0.90
line_graphMethod · 0.80
listsendpaysMethod · 0.80
wait_for_logMethod · 0.80
getinfoMethod · 0.45
invoiceMethod · 0.45
disconnectMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected