@@ -10,7 +10,10 @@ use node::{
10
10
11
11
use crate :: {
12
12
node:: RustNodeTestingConfig ,
13
- scenarios:: { add_rust_nodes, wait_for_nodes_listening_on_localhost, ClusterRunner , Driver } ,
13
+ scenarios:: {
14
+ add_rust_nodes, run_until_no_events, wait_for_nodes_listening_on_localhost, ClusterRunner ,
15
+ Driver ,
16
+ } ,
14
17
} ;
15
18
16
19
fn has_active_peer ( p2p_state : & P2pState , peer_id : & PeerId ) -> bool {
@@ -55,11 +58,17 @@ impl SimultaneousConnections {
55
58
. expect ( "connect event should be dispatched" ) ;
56
59
57
60
// Run the cluster while there are events
58
- while driver
59
- . run_until ( Duration :: from_secs ( 30 ) , |_, _, _| true )
60
- . await
61
- . unwrap ( )
62
- { }
61
+ let quiet = run_until_no_events (
62
+ & mut driver,
63
+ Duration :: from_secs ( 30 ) ,
64
+ Duration :: from_secs ( 60 ) ,
65
+ )
66
+ . await
67
+ . unwrap ( ) ;
68
+ assert ! (
69
+ quiet,
70
+ "no quiet period with no events since nodes are connected"
71
+ ) ;
63
72
64
73
let p2p_state1 = & driver. inner ( ) . node ( node1) . unwrap ( ) . state ( ) . p2p ;
65
74
let p2p_state2 = & driver. inner ( ) . node ( node2) . unwrap ( ) . state ( ) . p2p ;
@@ -125,17 +134,17 @@ impl AllNodesConnectionsAreSymmetric {
125
134
. collect ( ) ;
126
135
127
136
// Run the cluster while there are events
128
- let timeout = std :: time :: Instant :: now ( ) + Duration :: from_secs ( 2 * 60 ) ;
129
- while driver
130
- . run_until ( Duration :: from_secs ( 30 ) , |_ , _ , _| true )
131
- . await
132
- . unwrap ( )
133
- {
134
- assert ! (
135
- std :: time :: Instant :: now ( ) < timeout ,
136
- "cluster should stop generating events"
137
- ) ;
138
- }
137
+ let quiet = run_until_no_events (
138
+ & mut driver,
139
+ Duration :: from_secs ( 30 ) ,
140
+ Duration :: from_secs ( 2 * 60 ) ,
141
+ )
142
+ . await
143
+ . unwrap ( ) ;
144
+ assert ! (
145
+ quiet ,
146
+ "no quiet period with no events since nodes are connected"
147
+ ) ;
139
148
140
149
// Check that for each peer, if it is in the node's peer list, then the node is in the peer's peer list
141
150
for ( peer1, peer_id1) in & peers {
@@ -343,8 +352,10 @@ impl ConnectionStability {
343
352
const CONNECTED_TIME_SEC : u64 = 1 * 60 ;
344
353
let mut driver = Driver :: new ( runner) ;
345
354
346
- let ( node1, _) = driver. add_rust_node ( RustNodeTestingConfig :: berkeley_default ( ) . max_peers ( 1 ) ) ;
347
- let ( node2, _) = driver. add_rust_node ( RustNodeTestingConfig :: berkeley_default ( ) . max_peers ( 1 ) ) ;
355
+ let ( node1, _) =
356
+ driver. add_rust_node ( RustNodeTestingConfig :: berkeley_default ( ) . max_peers ( 1 ) ) ;
357
+ let ( node2, _) =
358
+ driver. add_rust_node ( RustNodeTestingConfig :: berkeley_default ( ) . max_peers ( 1 ) ) ;
348
359
349
360
assert ! (
350
361
wait_for_nodes_listening_on_localhost( & mut driver, Duration :: from_secs( 30 ) , [ node2] )
0 commit comments