@@ -2742,7 +2742,7 @@ mod tests {
2742
2742
2743
2743
use crate :: sync:: { Arc , Mutex } ;
2744
2744
use core:: convert:: Infallible ;
2745
- use core:: sync:: atomic:: { AtomicBool , Ordering } ;
2745
+ use core:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
2746
2746
2747
2747
#[ allow( unused_imports) ]
2748
2748
use crate :: prelude:: * ;
@@ -2894,20 +2894,25 @@ mod tests {
2894
2894
}
2895
2895
2896
2896
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
+
2897
2900
let id_a = peer_a. node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ;
2898
2901
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 ( ) ) ) ,
2900
2903
disconnect : Arc :: new ( AtomicBool :: new ( false ) ) ,
2901
2904
} ;
2902
2905
let addr_a = SocketAddress :: TcpIpV4 { addr : [ 127 , 0 , 0 , 1 ] , port : 1000 } ;
2906
+
2903
2907
let id_b = peer_b. node_signer . get_node_id ( Recipient :: Node ) . unwrap ( ) ;
2904
2908
let features_a = peer_a. init_features ( id_b) ;
2905
2909
let features_b = peer_b. init_features ( id_a) ;
2906
2910
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 ( ) ) ) ,
2908
2912
disconnect : Arc :: new ( AtomicBool :: new ( false ) ) ,
2909
2913
} ;
2910
2914
let addr_b = SocketAddress :: TcpIpV4 { addr : [ 127 , 0 , 0 , 1 ] , port : 1001 } ;
2915
+
2911
2916
let initial_data = peer_b. new_outbound_connection ( id_a, fd_b. clone ( ) , Some ( addr_a. clone ( ) ) ) . unwrap ( ) ;
2912
2917
peer_a. new_inbound_connection ( fd_a. clone ( ) , Some ( addr_b. clone ( ) ) ) . unwrap ( ) ;
2913
2918
assert_eq ! ( peer_a. read_event( & mut fd_a, & initial_data) . unwrap( ) , false ) ;
0 commit comments