@@ -285,23 +285,27 @@ async fn test_invariant_shrink() {
285
285
#[ tokio:: test( flavor = "multi_thread" ) ]
286
286
#[ cfg_attr( windows, ignore = "for some reason there's different rng" ) ]
287
287
async fn test_invariant_assert_shrink ( ) {
288
- // ensure assert and require shrinks to same sequence of 3 or less
289
- test_shrink ( "invariant_with_assert" ) . await ;
290
- test_shrink ( "invariant_with_require" ) . await ;
288
+ // ensure assert shrinks to same sequence of 2 as require
289
+ check_shrink_sequence ( "invariant_with_assert" , 2 ) . await ;
291
290
}
292
291
293
- async fn test_shrink ( test_pattern : & str ) {
294
- let mut opts = TEST_DATA_DEFAULT . test_opts . clone ( ) ;
295
- opts. fuzz . seed = Some ( U256 :: from ( 100u32 ) ) ;
292
+ #[ tokio:: test( flavor = "multi_thread" ) ]
293
+ #[ cfg_attr( windows, ignore = "for some reason there's different rng" ) ]
294
+ async fn test_invariant_require_shrink ( ) {
295
+ // ensure require shrinks to same sequence of 2 as assert
296
+ check_shrink_sequence ( "invariant_with_require" , 2 ) . await ;
297
+ }
298
+
299
+ async fn check_shrink_sequence ( test_pattern : & str , expected_len : usize ) {
296
300
let filter =
297
301
Filter :: new ( test_pattern, ".*" , ".*fuzz/invariant/common/InvariantShrinkWithAssert.t.sol" ) ;
298
302
let mut runner = TEST_DATA_DEFAULT . runner ( ) ;
299
- runner. test_options = opts ;
303
+ runner. test_options . fuzz . seed = Some ( U256 :: from ( 100u32 ) ) ;
300
304
301
305
match get_counterexample ! ( runner, & filter) {
302
306
CounterExample :: Single ( _) => panic ! ( "CounterExample should be a sequence." ) ,
303
307
CounterExample :: Sequence ( sequence) => {
304
- assert ! ( sequence. len( ) <= 3 ) ;
308
+ assert_eq ! ( sequence. len( ) , expected_len ) ;
305
309
}
306
310
} ;
307
311
}
0 commit comments