Skip to content

Commit e6104bc

Browse files
committed
pytest: test for askrene infinite loop with maxparts set.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 82fff3c commit e6104bc

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

tests/test_askrene.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pyln.testing.utils import SLOW_MACHINE
55
from utils import (
66
only_one, first_scid, GenChannel, generate_gossip_store,
7-
sync_blockheight, wait_for, TEST_NETWORK, TIMEOUT
7+
sync_blockheight, wait_for, TEST_NETWORK, TIMEOUT, mine_funding_to_announce
88
)
99
import os
1010
import pytest
@@ -1536,3 +1536,40 @@ def test_simple_dummy_channel(node_factory):
15361536
final_cltv=5,
15371537
layers=["mylayer"],
15381538
)
1539+
1540+
1541+
@pytest.mark.xfail(strict=True)
1542+
def test_maxparts_infloop(node_factory, bitcoind):
1543+
# Three paths from l1 -> l5.
1544+
# FIXME: enhance explain_failure!
1545+
l1, l2, l3, l4, l5 = node_factory.get_nodes(5, opts=[{'broken_log': 'plugin-cln-askrene.*the obvious route'}] + [{}] * 4)
1546+
1547+
for intermediate in (l2, l3, l4):
1548+
node_factory.join_nodes([l1, intermediate, l5])
1549+
1550+
# We create exorbitant fees into l3.
1551+
for n in (l2, l3, l4):
1552+
n.rpc.setchannel(l5.info['id'], feeppm=100000)
1553+
1554+
mine_funding_to_announce(bitcoind, (l1, l2, l3, l4, l5))
1555+
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 12)
1556+
1557+
amount=1_400_000_000
1558+
# You can do this one
1559+
route = l1.rpc.getroutes(source=l1.info['id'],
1560+
destination=l5.info['id'],
1561+
amount_msat=amount,
1562+
layers=[],
1563+
maxfee_msat=amount,
1564+
final_cltv=5)
1565+
assert len(route['routes']) == 3
1566+
1567+
# Now with maxparts == 2:
1568+
with pytest.raises(RpcError, match="Actually, I'm not sure why we didn't find the obvious route"):
1569+
l1.rpc.getroutes(source=l1.info['id'],
1570+
destination=l5.info['id'],
1571+
amount_msat=amount,
1572+
layers=[],
1573+
maxfee_msat=amount,
1574+
final_cltv=5,
1575+
maxparts=2)

0 commit comments

Comments
 (0)