Browse Source

gossipd/routing.c: Correctly handle a duplicated entry in `exclude` of `getroute`.

pull/2938/head
ZmnSCPxj 6 years ago
committed by Christian Decker
parent
commit
3e74ca4b86
  1. 11
      gossipd/routing.c
  2. 1
      tests/test_gossip.py

11
gossipd/routing.c

@ -2334,7 +2334,16 @@ struct route_hop *get_route(const tal_t *ctx, struct routing_state *rstate,
fuzz, &base_seed, max_hops, &fee); fuzz, &base_seed, max_hops, &fee);
/* Now restore the capacity. */ /* Now restore the capacity. */
for (size_t i = 0; i < tal_count(excluded); i++) { /* Restoring is done in reverse order, in order to properly
* handle the case where a channel is indicated twice in
* our input.
* Entries in `saved_capacity` of that channel beyond the
* first entry will be 0, only the first entry of that
* channel will be the correct capacity.
* By restoring in reverse order we ensure we can restore
* the correct capacity.
*/
for (ssize_t i = tal_count(excluded) - 1; i >= 0; i--) {
struct chan *chan = get_channel(rstate, &excluded[i].scid); struct chan *chan = get_channel(rstate, &excluded[i].scid);
if (!chan) if (!chan)
continue; continue;

1
tests/test_gossip.py

@ -1057,7 +1057,6 @@ def test_gossip_notices_close(node_factory, bitcoind):
assert(l1.rpc.listnodes()['nodes'] == []) assert(l1.rpc.listnodes()['nodes'] == [])
@pytest.mark.xfail(strict=True)
def test_getroute_exclude_duplicate(node_factory): def test_getroute_exclude_duplicate(node_factory):
"""Test that accidentally duplicating the same channel in """Test that accidentally duplicating the same channel in
the exclude list will not have permanent effects. the exclude list will not have permanent effects.

Loading…
Cancel
Save