11use std:: { future:: ready, time:: Duration } ;
22
3- use p2p:: PeerId ;
3+ use p2p:: { P2pNetworkConnectionState , PeerId } ;
44use p2p_testing:: {
55 cluster:: { Cluster , ClusterBuilder , ClusterEvent , NodeId } ,
66 event:: { allow_disconnections, RustNodeEvent } ,
@@ -10,8 +10,9 @@ use p2p_testing::{
1010 rust_node:: { RustNodeConfig , RustNodeId } ,
1111 stream:: ClusterStreamExt ,
1212 utils:: {
13- peer_ids, rust_nodes_from_default_config, try_wait_for_all_nodes_to_connect,
14- try_wait_for_nodes_to_connect, wait_for_all_nodes_to_listen,
13+ peer_ids, rust_nodes_from_default_config, try_run_cluster,
14+ try_wait_for_all_nodes_to_connect, try_wait_for_nodes_to_connect,
15+ wait_for_all_nodes_to_listen,
1516 } ,
1617} ;
1718
@@ -30,7 +31,7 @@ fn assert_peer_is_ready(cluster: &Cluster, id: RustNodeId, peer_id: PeerId) {
3031fn assert_single_connection ( cluster : & Cluster , id : RustNodeId , peer_id : PeerId ) {
3132 let state = cluster. rust_node ( id) . state ( ) ;
3233 let my_id = cluster. peer_id ( id) ;
33- let mut found = None ;
34+ let mut found: Option < & P2pNetworkConnectionState > = None ;
3435 for ( addr, conn_state) in & state. network . scheduler . connections {
3536 let conn_peer_id = conn_state. peer_id ( ) ;
3637 assert ! (
@@ -195,15 +196,19 @@ async fn mutual_rust_to_rust_many() -> anyhow::Result<()> {
195196 node_to_node
196197 . clone ( )
197198 . try_for_each ( |( n1, n2) | cluster. connect ( n1, n2) ) ?;
199+
198200 let node_to_peer = node_to_node
199201 . map ( |( n1, n2) | ( n1, cluster. peer_id ( n2) ) )
200202 . collect :: < Vec < _ > > ( ) ;
201203
202204 let connected =
203205 try_wait_for_nodes_to_connect ( & mut cluster, node_to_peer. clone ( ) , Duration :: from_secs ( 10 ) )
204206 . await ?;
207+
205208 assert ! ( connected) ;
206209
210+ try_run_cluster ( & mut cluster, Duration :: from_secs ( 5 ) ) . await ?;
211+
207212 for ( node, peer_id) in node_to_peer {
208213 assert_peer_is_ready ( & cluster, node, peer_id) ;
209214 assert_single_connection ( & cluster, node, peer_id) ;
0 commit comments