Skip to content

Commit 15fa0d8

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 8012c2b commit 15fa0d8

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
@@ -3259,30 +3259,34 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
32593259

32603260
for i in 0..node_count {
32613261
for j in (i+1)..node_count {
3262-
let node_id_i = nodes[i].node.get_our_node_id();
3263-
let node_id_j = nodes[j].node.get_our_node_id();
3264-
3265-
let init_i = msgs::Init {
3266-
features: nodes[i].init_features(&node_id_j),
3267-
networks: None,
3268-
remote_network_address: None,
3269-
};
3270-
let init_j = msgs::Init {
3271-
features: nodes[j].init_features(&node_id_i),
3272-
networks: None,
3273-
remote_network_address: None,
3274-
};
3275-
3276-
nodes[i].node.peer_connected(&node_id_j, &init_j, true).unwrap();
3277-
nodes[j].node.peer_connected(&node_id_i, &init_i, false).unwrap();
3278-
nodes[i].onion_messenger.peer_connected(&node_id_j, &init_j, true).unwrap();
3279-
nodes[j].onion_messenger.peer_connected(&node_id_i, &init_i, false).unwrap();
3262+
connect_nodes(&nodes[i], &nodes[j]);
32803263
}
32813264
}
32823265

32833266
nodes
32843267
}
32853268

3269+
fn connect_nodes<'a, 'b: 'a, 'c: 'b>(node_a: &Node<'a, 'b, 'c>, node_b: &Node<'a, 'b, 'c>) {
3270+
let node_id_a = node_a.node.get_our_node_id();
3271+
let node_id_b = node_b.node.get_our_node_id();
3272+
3273+
let init_a = msgs::Init {
3274+
features: node_a.init_features(&node_id_b),
3275+
networks: None,
3276+
remote_network_address: None,
3277+
};
3278+
let init_b = msgs::Init {
3279+
features: node_b.init_features(&node_id_a),
3280+
networks: None,
3281+
remote_network_address: None,
3282+
};
3283+
3284+
node_a.node.peer_connected(&node_id_b, &init_b, true).unwrap();
3285+
node_b.node.peer_connected(&node_id_a, &init_a, false).unwrap();
3286+
node_a.onion_messenger.peer_connected(&node_id_b, &init_b, true).unwrap();
3287+
node_b.onion_messenger.peer_connected(&node_id_a, &init_a, false).unwrap();
3288+
}
3289+
32863290
pub fn connect_dummy_node<'a, 'b: 'a, 'c: 'b>(node: &Node<'a, 'b, 'c>) {
32873291
let node_id_dummy = PublicKey::from_slice(&[2; 33]).unwrap();
32883292

@@ -3643,13 +3647,8 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
36433647
pending_cell_htlc_claims, pending_cell_htlc_fails, pending_raa,
36443648
pending_responding_commitment_signed, pending_responding_commitment_signed_dup_monitor,
36453649
} = args;
3646-
node_a.node.peer_connected(&node_b.node.get_our_node_id(), &msgs::Init {
3647-
features: node_b.node.init_features(), networks: None, remote_network_address: None
3648-
}, true).unwrap();
3650+
connect_nodes(node_a, node_b);
36493651
let reestablish_1 = get_chan_reestablish_msgs!(node_a, node_b);
3650-
node_b.node.peer_connected(&node_a.node.get_our_node_id(), &msgs::Init {
3651-
features: node_a.node.init_features(), networks: None, remote_network_address: None
3652-
}, false).unwrap();
36533652
let reestablish_2 = get_chan_reestablish_msgs!(node_b, node_a);
36543653

36553654
if send_channel_ready.0 {

0 commit comments

Comments
 (0)