MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_getroute_exclude_duplicate

Function test_getroute_exclude_duplicate

tests/test_gossip.py:1472–1505  ·  view source on GitHub ↗

Test that accidentally duplicating the same channel or same node in the exclude list will not have permanent effects.

(node_factory)

Source from the content-addressed store, hash-verified

1470
1471
1472def test_getroute_exclude_duplicate(node_factory):
1473 """Test that accidentally duplicating the same channel or same node
1474 in the exclude list will not have permanent effects.
1475 """
1476
1477 l1, l2 = node_factory.line_graph(2, wait_for_announce=True,
1478 opts={'allow-deprecated-apis': True})
1479
1480 # Starting route
1481 route = l1.rpc.getroute(l2.info['id'], 1, 1)['route']
1482 # l1 id is > l2 id, so 1 means l1->l2
1483 chan_l1l2 = route[0]['channel'] + '/1'
1484
1485 # This should fail to find a route as the only viable channel
1486 # is excluded, and worse, is excluded twice.
1487 with pytest.raises(RpcError):
1488 l1.rpc.getroute(l2.info['id'], 1, 1, exclude=[chan_l1l2, chan_l1l2])
1489
1490 # This should still succeed since nothing is excluded anymore
1491 # and in particular should return the exact same route as
1492 # earlier.
1493 route2 = l1.rpc.getroute(l2.info['id'], 1, 1)['route']
1494 assert route == route2
1495
1496 # This should also fail to find a route as the only viable channel
1497 # is excluded, and worse, is excluded twice.
1498 with pytest.raises(RpcError):
1499 l1.rpc.getroute(l2.info['id'], 1, 1, exclude=[l2.info['id'], l2.info['id']])
1500
1501 # This should still succeed since nothing is excluded anymore
1502 # and in particular should return the exact same route as
1503 # earlier.
1504 route3 = l1.rpc.getroute(l2.info['id'], 1, 1)['route']
1505 assert route == route3
1506
1507
1508def test_getroute_exclude(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 2

line_graphMethod · 0.80
getrouteMethod · 0.80

Tested by

no test coverage detected