Skip to content

Commit 692d9b2

Browse files
committed
f simplify test
1 parent 0b6fa30 commit 692d9b2

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4915,29 +4915,10 @@ mod tests {
49154915
let peers = create_network(2, &cfgs);
49164916

49174917
let id_0 = peers[0].node_signer.get_node_id(Recipient::Node).unwrap();
4918-
let addr_0 = SocketAddress::TcpIpV4 { addr: [127, 0, 0, 1], port: 1000 };
4919-
let addr_1 = SocketAddress::TcpIpV4 { addr: [127, 0, 0, 1], port: 1001 };
49204918

4921-
let mut fd_0_1 = FileDescriptor::new(1);
4922-
let mut fd_1_0 = FileDescriptor::new(2);
4923-
4924-
// Connect the peers and exchange the initial connection handshake.
4925-
let initial_data =
4926-
peers[1].new_outbound_connection(id_0, fd_1_0.clone(), Some(addr_0)).unwrap();
4927-
peers[0].new_inbound_connection(fd_0_1.clone(), Some(addr_1)).unwrap();
4928-
peers[0].read_event(&mut fd_0_1, &initial_data).unwrap();
4929-
4930-
peers[0].process_events();
4931-
let data_0_1 = fd_0_1.outbound_data.lock().unwrap().split_off(0);
4932-
peers[1].read_event(&mut fd_1_0, &data_0_1).unwrap();
4933-
4934-
peers[1].process_events();
4935-
let data_1_0 = fd_1_0.outbound_data.lock().unwrap().split_off(0);
4936-
peers[0].read_event(&mut fd_0_1, &data_1_0).unwrap();
4937-
4938-
peers[0].process_events();
4939-
let data_0_1 = fd_0_1.outbound_data.lock().unwrap().split_off(0);
4940-
peers[1].read_event(&mut fd_1_0, &data_0_1).unwrap();
4919+
// Connect the peers and exchange the initial connection handshake (but not the final Init
4920+
// message).
4921+
let (mut fd_0_1, mut fd_1_0) = establish_connection(&peers[0], &peers[1]);
49414922

49424923
// Once peer 1 receives the Init message in the last read_event, it'll generate a
49434924
// `GossipTimestampFilter` which will request gossip. Instead we drop it here.
@@ -4950,7 +4931,7 @@ mod tests {
49504931

49514932
peers[1].process_events();
49524933
let data_1_0 = fd_1_0.outbound_data.lock().unwrap().split_off(0);
4953-
peers[0].read_event(&mut fd_0_1, &data_1_0).unwrap();
4934+
peers[0].read_event(&mut fd_0_1, &data_1_0).unwrap(); // Init message
49544935

49554936
peers[0].process_events();
49564937
assert!(fd_0_1.outbound_data.lock().unwrap().is_empty());

0 commit comments

Comments
 (0)