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

Function test_injectpaymentonion_peerfail

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

Source from the content-addressed store, hash-verified

6782
6783
6784def test_injectpaymentonion_peerfail(node_factory, executor):
6785 l1, l2 = node_factory.line_graph(2,
6786 opts=[{'may_reconnect': True,
6787 'dev-no-reconnect': None,
6788 'disconnect': ['=WIRE_UPDATE_ADD_HTLC', '-WIRE_COMMITMENT_SIGNED']},
6789 {'may_reconnect': True,
6790 'dev-no-reconnect': None}])
6791 blockheight = l1.rpc.getinfo()['blockheight']
6792
6793 inv1 = l2.rpc.invoice(1000, "test_injectpaymentonion_peerfail", "test_injectpaymentonion_peerfail")
6794
6795 # First hop for injectpaymentonion is self.
6796 hops = [{'pubkey': l1.info['id'],
6797 'payload': serialize_payload_tlv(1000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6798 {'pubkey': l2.info['id'],
6799 'payload': serialize_payload_final_tlv(1000, 18, 1000, blockheight, inv1['payment_secret']).hex()}]
6800 onion = l1.rpc.createonion(hops=hops, assocdata=inv1['payment_hash'])
6801
6802 l1.rpc.disconnect(l2.info['id'], force=True)
6803 with pytest.raises(RpcError, match='WIRE_TEMPORARY_CHANNEL_FAILURE'):
6804 l1.rpc.injectpaymentonion(onion=onion['onion'],
6805 payment_hash=inv1['payment_hash'],
6806 amount_msat=1000,
6807 cltv_expiry=blockheight + 18 + 6,
6808 partid=1,
6809 groupid=0)
6810 # In fact, it won't create any sendpays entry, since it fails too early.
6811 assert l1.rpc.listsendpays() == {'payments': []}
6812
6813 # This will hang, since we disconnect once committed. But provides another
6814 # (legitimately) pending payment for our migration code to test.
6815 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
6816 executor.submit(l1.rpc.injectpaymentonion,
6817 onion=onion['onion'],
6818 payment_hash=inv1['payment_hash'],
6819 amount_msat=1000,
6820 cltv_expiry=blockheight + 18 + 6,
6821 partid=2,
6822 groupid=0)
6823 l1.daemon.wait_for_log("dev_disconnect: =WIRE_UPDATE_ADD_HTLC")
6824 assert [p['status'] for p in l1.rpc.listsendpays()['payments']] == ['pending']
6825
6826
6827def 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