@@ -2742,7 +2742,7 @@ mod tests {
27422742
27432743 use crate :: sync:: { Arc , Mutex } ;
27442744 use core:: convert:: Infallible ;
2745- use core:: sync:: atomic:: { AtomicBool , Ordering } ;
2745+ use core:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
27462746
27472747 #[ allow( unused_imports) ]
27482748 use crate :: prelude:: * ;
@@ -2894,20 +2894,25 @@ mod tests {
28942894 }
28952895
28962896 fn establish_connection < ' a > ( peer_a : & PeerManager < FileDescriptor , & ' a test_utils:: TestChannelMessageHandler , & ' a test_utils:: TestRoutingMessageHandler , IgnoringMessageHandler , & ' a test_utils:: TestLogger , & ' a TestCustomMessageHandler , & ' a test_utils:: TestNodeSigner > , peer_b : & PeerManager < FileDescriptor , & ' a test_utils:: TestChannelMessageHandler , & ' a test_utils:: TestRoutingMessageHandler , IgnoringMessageHandler , & ' a test_utils:: TestLogger , & ' a TestCustomMessageHandler , & ' a test_utils:: TestNodeSigner > ) -> ( FileDescriptor , FileDescriptor ) {
2897+ static FD_COUNTER : AtomicUsize = AtomicUsize :: new ( 0 ) ;
2898+ let fd = FD_COUNTER . fetch_add ( 1 , Ordering :: Relaxed ) as u16 ;
2899+
28972900 let id_a = peer_a. node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ;
28982901 let mut fd_a = FileDescriptor {
2899- fd : 1 , outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
2902+ fd, outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
29002903 disconnect : Arc :: new ( AtomicBool :: new ( false ) ) ,
29012904 } ;
29022905 let addr_a = SocketAddress :: TcpIpV4 { addr : [ 127 , 0 , 0 , 1 ] , port : 1000 } ;
2906+
29032907 let id_b = peer_b. node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ;
29042908 let features_a = peer_a. init_features ( id_b) ;
29052909 let features_b = peer_b. init_features ( id_a) ;
29062910 let mut fd_b = FileDescriptor {
2907- fd : 1 , outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
2911+ fd, outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
29082912 disconnect : Arc :: new ( AtomicBool :: new ( false ) ) ,
29092913 } ;
29102914 let addr_b = SocketAddress :: TcpIpV4 { addr : [ 127 , 0 , 0 , 1 ] , port : 1001 } ;
2915+
29112916 let initial_data = peer_b. new_outbound_connection ( id_a, fd_b. clone ( ) , Some ( addr_a. clone ( ) ) ) . unwrap ( ) ;
29122917 peer_a. new_inbound_connection ( fd_a. clone ( ) , Some ( addr_b. clone ( ) ) ) . unwrap ( ) ;
29132918 assert_eq ! ( peer_a. read_event( & mut fd_a, & initial_data) . unwrap( ) , false ) ;
0 commit comments