diff --git a/tests/test_pay.py b/tests/test_pay.py index 5f6617ca16ed..11f40fa8077c 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2880,3 +2880,19 @@ def test_reject_invalid_payload(node_factory): with pytest.raises(RpcError, match=r'WIRE_INVALID_ONION_PAYLOAD'): 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're be forced to use routehint, since we don't know about l3. + 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)