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