Skip to content

Commit 350578d

Browse files
committed
pytest: test that we correctly mark a payment part failed if we cannot queue it to the channeld for the peer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 43d7db7 commit 350578d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/test_pay.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6755,6 +6755,50 @@ def test_injectpaymentonion_failures(node_factory, executor):
67556755
assert 'onionreply' in err.value.error['data']
67566756

67576757

6758+
@pytest.mark.xfail(strict=True)
6759+
def test_injectpaymentonion_peerfail(node_factory, executor):
6760+
l1, l2 = node_factory.line_graph(2,
6761+
opts=[{'may_reconnect': True,
6762+
'dev-no-reconnect': None,
6763+
'disconnect': ['=WIRE_UPDATE_ADD_HTLC', '-WIRE_COMMITMENT_SIGNED']},
6764+
{'may_reconnect': True,
6765+
'dev-no-reconnect': None}])
6766+
blockheight = l1.rpc.getinfo()['blockheight']
6767+
6768+
inv1 = l2.rpc.invoice(1000, "test_injectpaymentonion_peerfail", "test_injectpaymentonion_peerfail")
6769+
6770+
# First hop for injectpaymentonion is self.
6771+
hops = [{'pubkey': l1.info['id'],
6772+
'payload': serialize_payload_tlv(1000, 18 + 6, first_scid(l1, l2), blockheight).hex()},
6773+
{'pubkey': l2.info['id'],
6774+
'payload': serialize_payload_final_tlv(1000, 18, 1000, blockheight, inv1['payment_secret']).hex()}]
6775+
onion = l1.rpc.createonion(hops=hops, assocdata=inv1['payment_hash'])
6776+
6777+
l1.rpc.disconnect(l2.info['id'], force=True)
6778+
with pytest.raises(RpcError, match='WIRE_TEMPORARY_CHANNEL_FAILURE'):
6779+
l1.rpc.injectpaymentonion(onion=onion['onion'],
6780+
payment_hash=inv1['payment_hash'],
6781+
amount_msat=1000,
6782+
cltv_expiry=blockheight + 18 + 6,
6783+
partid=1,
6784+
groupid=0)
6785+
# In fact, it won't create any sendpays entry, since it fails too early.
6786+
assert l1.rpc.listsendpays() == {'payments': []}
6787+
6788+
# This will hang, since we disconnect once committed. But provides another
6789+
# (legitimately) pending payment for our migration code to test.
6790+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
6791+
executor.submit(l1.rpc.injectpaymentonion,
6792+
onion=onion['onion'],
6793+
payment_hash=inv1['payment_hash'],
6794+
amount_msat=1000,
6795+
cltv_expiry=blockheight + 18 + 6,
6796+
partid=2,
6797+
groupid=0)
6798+
l1.daemon.wait_for_log("dev_disconnect: =WIRE_UPDATE_ADD_HTLC")
6799+
assert [p['status'] for p in l1.rpc.listsendpays()['payments']] == ['pending']
6800+
6801+
67586802
def test_parallel_channels_reserve(node_factory, bitcoind):
67596803
"""Tests wether we are able to pay through parallel channels concurrently.
67606804
To do that we need to enable strict-forwarding."""

0 commit comments

Comments
 (0)