Browse Source

pytest: test for pay adjacent routehint crash.

When route returns a result which is too expensive, we try to figure out which
hop is most expensive to exclude it for next time.

If it's a single-hop route, we don't count it, since the first hop is free.
That's not usually a problem, since single-hop routes can't exceed our limits
(they're always "free"!).

But if we are using a routehint, the total cost could exceed our limits,
even if the start of the routehint is a single hop away.

This reproduces that test case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
register-keysend-plugin
Rusty Russell 5 years ago
committed by neil saitug
parent
commit
1dc281c111
  1. 17
      tests/test_pay.py

17
tests/test_pay.py

@ -2942,3 +2942,20 @@ def test_sendpay_blinding(node_factory):
payment_hash=inv['payment_hash'], payment_hash=inv['payment_hash'],
bolt11=inv['bolt11']) bolt11=inv['bolt11'])
l1.rpc.waitsendpay(inv['payment_hash']) l1.rpc.waitsendpay(inv['payment_hash'])
def test_excluded_adjacent_routehint(node_factory, bitcoind):
"""Test case where we try have a routehint which leads to an adjacent
node, but the result exceeds our maxfee; we crashed trying to find
what part of the path was most expensive in that case
"""
l1, l2, l3 = node_factory.line_graph(3)
# We'll be forced to use routehint, since we don't know about l3.
wait_for(lambda: l3.channel_state(l2) == 'CHANNELD_NORMAL')
inv = l3.rpc.invoice(10**3, "lbl", "desc", exposeprivatechannels=l2.get_channel_scid(l3))
# This will make it reject the routehint.
with pytest.raises(RpcError, match=r'Route wanted fee of 1msat'):
l1.rpc.pay(bolt11=inv['bolt11'], maxfeepercent=0, exemptfee=0)

Loading…
Cancel
Save