@@ -2743,7 +2743,7 @@ mod tests {
27432743
27442744 use crate :: sync:: { Arc , Mutex } ;
27452745 use core:: convert:: Infallible ;
2746- use core:: sync:: atomic:: { AtomicBool , Ordering } ;
2746+ use core:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
27472747
27482748 #[ allow( unused_imports) ]
27492749 use crate :: prelude:: * ;
@@ -2895,20 +2895,25 @@ mod tests {
28952895 }
28962896
28972897 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 ) {
2898+ static FD_COUNTER : AtomicUsize = AtomicUsize :: new ( 0 ) ;
2899+ let fd = FD_COUNTER . fetch_add ( 1 , Ordering :: Relaxed ) as u16 ;
2900+
28982901 let id_a = peer_a. node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ;
28992902 let mut fd_a = FileDescriptor {
2900- fd : 1 , outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
2903+ fd, outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
29012904 disconnect : Arc :: new ( AtomicBool :: new ( false ) ) ,
29022905 } ;
29032906 let addr_a = SocketAddress :: TcpIpV4 { addr : [ 127 , 0 , 0 , 1 ] , port : 1000 } ;
2907+
29042908 let id_b = peer_b. node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ;
29052909 let features_a = peer_a. init_features ( & id_b) ;
29062910 let features_b = peer_b. init_features ( & id_a) ;
29072911 let mut fd_b = FileDescriptor {
2908- fd : 1 , outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
2912+ fd, outbound_data : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
29092913 disconnect : Arc :: new ( AtomicBool :: new ( false ) ) ,
29102914 } ;
29112915 let addr_b = SocketAddress :: TcpIpV4 { addr : [ 127 , 0 , 0 , 1 ] , port : 1001 } ;
2916+
29122917 let initial_data = peer_b. new_outbound_connection ( id_a, fd_b. clone ( ) , Some ( addr_a. clone ( ) ) ) . unwrap ( ) ;
29132918 peer_a. new_inbound_connection ( fd_a. clone ( ) , Some ( addr_b. clone ( ) ) ) . unwrap ( ) ;
29142919 assert_eq ! ( peer_a. read_event( & mut fd_a, & initial_data) . unwrap( ) , false ) ;
0 commit comments