Skip to content

Commit ccff9a2

Browse files
committed
Fix functional_test_utils::reconnect_nodes
When reconnecting nodes, make sure to notify OnionMessenger that the nodes are now connected.
1 parent b4026fd commit ccff9a2

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,30 +3249,34 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
32493249

32503250
for i in 0..node_count {
32513251
for j in (i+1)..node_count {
3252-
let node_id_i = nodes[i].node.get_our_node_id();
3253-
let node_id_j = nodes[j].node.get_our_node_id();
3254-
3255-
let init_i = msgs::Init {
3256-
features: nodes[i].init_features(&node_id_j),
3257-
networks: None,
3258-
remote_network_address: None,
3259-
};
3260-
let init_j = msgs::Init {
3261-
features: nodes[j].init_features(&node_id_i),
3262-
networks: None,
3263-
remote_network_address: None,
3264-
};
3265-
3266-
nodes[i].node.peer_connected(&node_id_j, &init_j, true).unwrap();
3267-
nodes[j].node.peer_connected(&node_id_i, &init_i, false).unwrap();
3268-
nodes[i].onion_messenger.peer_connected(&node_id_j, &init_j, true).unwrap();
3269-
nodes[j].onion_messenger.peer_connected(&node_id_i, &init_i, false).unwrap();
3252+
connect_nodes(&nodes[i], &nodes[j]);
32703253
}
32713254
}
32723255

32733256
nodes
32743257
}
32753258

3259+
fn connect_nodes<'a, 'b: 'a, 'c: 'b>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>) {
3260+
let node_id_a = node_a.node.get_our_node_id();
3261+
let node_id_b = node_b.node.get_our_node_id();
3262+
3263+
let init_a = msgs::Init {
3264+
features: node_a.init_features(&node_id_b),
3265+
networks: None,
3266+
remote_network_address: None,
3267+
};
3268+
let init_b = msgs::Init {
3269+
features: node_b.init_features(&node_id_a),
3270+
networks: None,
3271+
remote_network_address: None,
3272+
};
3273+
3274+
node_a.node.peer_connected(&node_id_b, &init_b, true).unwrap();
3275+
node_b.node.peer_connected(&node_id_a, &init_a, false).unwrap();
3276+
node_a.onion_messenger.peer_connected(&node_id_b, &init_b, true).unwrap();
3277+
node_b.onion_messenger.peer_connected(&node_id_a, &init_a, false).unwrap();
3278+
}
3279+
32763280
pub fn connect_dummy_node<'a, 'b: 'a, 'c: 'b>(node: &Node<'a, 'b, 'c>) {
32773281
let node_id_dummy = PublicKey::from_slice(&[2; 33]).unwrap();
32783282

@@ -3633,13 +3637,8 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
36333637
pending_cell_htlc_claims, pending_cell_htlc_fails, pending_raa,
36343638
pending_responding_commitment_signed, pending_responding_commitment_signed_dup_monitor,
36353639
} = args;
3636-
node_a.node.peer_connected(&node_b.node.get_our_node_id(), &msgs::Init {
3637-
features: node_b.node.init_features(), networks: None, remote_network_address: None
3638-
}, true).unwrap();
3640+
connect_nodes(node_a, node_b);
36393641
let reestablish_1 = get_chan_reestablish_msgs!(node_a, node_b);
3640-
node_b.node.peer_connected(&node_a.node.get_our_node_id(), &msgs::Init {
3641-
features: node_a.node.init_features(), networks: None, remote_network_address: None
3642-
}, false).unwrap();
36433642
let reestablish_2 = get_chan_reestablish_msgs!(node_b, node_a);
36443643

36453644
if send_channel_ready.0 {

0 commit comments

Comments
 (0)