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