Skip to content

Commit 599f5e0

Browse files
authored
fix(invariant): ensure strategy always generates valid sender (#11370)
* fix(invariant): ensure strategy always generates valid sender * Better comment
1 parent 2af2f02 commit 599f5e0

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

crates/evm/fuzz/src/strategies/invariants.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,20 @@ fn select_random_sender(
9797
100 - dictionary_weight => fuzz_param(&alloy_dyn_abi::DynSolType::Address),
9898
dictionary_weight => fuzz_param_from_state(&alloy_dyn_abi::DynSolType::Address, fuzz_state),
9999
]
100-
.prop_map(move |addr| addr.as_address().unwrap())
101-
// Too many exclusions can slow down testing.
102-
.prop_filter("excluded sender", move |addr| !senders.excluded.contains(addr))
100+
.prop_map(move |addr| {
101+
let mut addr = addr.as_address().unwrap();
102+
// Make sure the selected address is not in the list of excluded senders.
103+
// We don't use proptest's filter to avoid reaching the `PROPTEST_MAX_LOCAL_REJECTS`
104+
// max rejects and exiting test before all runs completes.
105+
// See <https://github.com/foundry-rs/foundry/issues/11369>.
106+
loop {
107+
if !senders.excluded.contains(&addr) {
108+
break;
109+
}
110+
addr = Address::random();
111+
}
112+
addr
113+
})
103114
.boxed()
104115
}
105116
}

0 commit comments

Comments
 (0)