Skip to content

Commit 2745bd5

Browse files
committed
Connect peers on startup in tests
This avoids `ChannelManager` ever being confused by the fact that it received a message from a peer which it didn't think it was connected to.
1 parent e26c9b0 commit 2745bd5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,6 +5180,12 @@ mod tests {
51805180
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
51815181
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
51825182

5183+
// All nodes start with a persistable update pending as `create_network` connects each node
5184+
// with all other nodes to make most tests simpler.
5185+
assert!(nodes[0].node.await_persistable_update_timeout(Duration::from_millis(1)));
5186+
assert!(nodes[1].node.await_persistable_update_timeout(Duration::from_millis(1)));
5187+
assert!(nodes[2].node.await_persistable_update_timeout(Duration::from_millis(1)));
5188+
51835189
let mut chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
51845190

51855191
// We check that the channel info nodes have doesn't change too early, even though we try

lightning/src/ln/functional_test_utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,13 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
14041404
})
14051405
}
14061406

1407+
for i in 0..node_count {
1408+
for j in (i+1)..node_count {
1409+
nodes[i].node.peer_connected(&nodes[j].node.get_our_node_id(), &msgs::Init { features: InitFeatures::known() });
1410+
nodes[j].node.peer_connected(&nodes[i].node.get_our_node_id(), &msgs::Init { features: InitFeatures::known() });
1411+
}
1412+
}
1413+
14071414
nodes
14081415
}
14091416

0 commit comments

Comments
 (0)