Skip to content

Commit

Permalink
fix: invariant tests with input args don't panic (#5766)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruvaag authored Aug 31, 2023
1 parent 3c954bc commit 577dae3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/evm/src/fuzz/invariant/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use ethers::{
abi::{Abi, Address, Detokenize, FixedBytes, Tokenizable, TokenizableItem},
prelude::U256,
};
use eyre::{ContextCompat, Result};
use eyre::{eyre, ContextCompat, Result};
use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact};
use foundry_config::{FuzzDictionaryConfig, InvariantConfig};
use parking_lot::{Mutex, RwLock};
Expand Down Expand Up @@ -99,6 +99,11 @@ impl<'a> InvariantExecutor<'a> {
&mut self,
invariant_contract: InvariantContract,
) -> Result<InvariantFuzzTestResult> {
// Throw an error to abort test run if the invariant function accepts input params
if !invariant_contract.invariant_function.inputs.is_empty() {
return Err(eyre!("Invariant test function should have no inputs"))
}

let (fuzz_state, targeted_contracts, strat) = self.prepare_fuzzing(&invariant_contract)?;

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

0 comments on commit 577dae3

Please sign in to comment.