Browse Source

tests/test_pay.py: Add test to replicate #3757.

paymod-01
ZmnSCPxj jxPCSnmZ 5 years ago
committed by Rusty Russell
parent
commit
a25af262e9
  1. 20
      tests/plugins/fail_htlcs_invalid.py
  2. 27
      tests/test_pay.py

20
tests/plugins/fail_htlcs_invalid.py

@ -0,0 +1,20 @@
#!/usr/bin/env python3
from pyln.client import Plugin
plugin = Plugin()
@plugin.hook("htlc_accepted")
def on_htlc_accepted(onion, plugin, **kwargs):
plugin.log("Failing htlc on purpose with invalid onion failure")
plugin.log("onion: %r" % (onion))
# WIRE_TEMPORARY_CHANNEL_FAILURE = 0x1007
# This failure code should be followed by a
# `channel_update`; we deliberately return
# a 0-length `channel_update` to trigger
# issue #3757 reported by @sumBTC.
return {"result": "fail", "failure_message": "10070000"}
plugin.run()

27
tests/test_pay.py

@ -3017,3 +3017,30 @@ def test_keysend(node_factory):
inv = invs[0]
assert(inv['msatoshi_received'] >= amt)
@pytest.mark.xfail(strict=True)
def test_invalid_onion_channel_update(node_factory):
'''
Some onion failures "should" send a `channel_update`.
This test checks to see if we handle things correctly
even if some remote node does not send the required
`channel_update`.
'''
plugin = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs_invalid.py')
l1, l2, l3 = node_factory.line_graph(3,
opts=[{},
{'plugin': plugin},
{}],
wait_for_announce=True)
l1id = l1.info['id']
inv = l3.rpc.invoice(12345, 'inv', 'inv')['bolt11']
# Should fail, since l2 will always fail to forward.
with pytest.raises(RpcError):
l1.rpc.pay(inv)
# l1 should still be alive afterwards.
assert l1.rpc.getinfo()['id'] == l1id

Loading…
Cancel
Save