Skip to content

Commit 577dae3

Browse files
authored
fix: invariant tests with input args don't panic (#5766)
1 parent 3c954bc commit 577dae3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/evm/src/fuzz/invariant/executor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ethers::{
2323
abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem},
2424
prelude::U256,
2525
};
26-
use eyre::{ContextCompat, Result};
26+
use eyre::{eyre, ContextCompat, Result};
2727
use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact};
2828
use foundry_config::{FuzzDictionaryConfig, InvariantConfig};
2929
use parking_lot::{Mutex, RwLock};
@@ -99,6 +99,11 @@ impl<'a> InvariantExecutor<'a> {
9999
&mut self,
100100
invariant_contract: InvariantContract,
101101
) -> Result<InvariantFuzzTestResult> {
102+
// Throw an error to abort test run if the invariant function accepts input params
103+
if !invariant_contract.invariant_function.inputs.is_empty() {
104+
return Err(eyre!("Invariant test function should have no inputs"))
105+
}
106+
102107
let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract)?;
103108

104109
// Stores the consumed gas and calldata of every successful fuzz call.

0 commit comments

Comments
 (0)