Skip to content

Commit

Permalink
pytest: test for pay adjacent routehint crash.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rustyrussell committed Apr 14, 2020
1 parent 6e58eb8 commit 79c5e0a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2942,3 +2942,20 @@ def test_sendpay_blinding(node_factory):
payment_hash=inv['payment_hash'],
bolt11=inv['bolt11'])
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)

0 comments on commit 79c5e0a

Please sign in to comment.