-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cheatcodes): add vm.assumeNoRevert for fuzz tests (#8780)
- Loading branch information
Showing
7 changed files
with
160 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::{Cheatcode, Cheatcodes, CheatsCtxt, Error, Result}; | ||
use foundry_evm_core::{backend::DatabaseExt, constants::MAGIC_ASSUME}; | ||
use spec::Vm::{assumeCall, assumeNoRevertCall}; | ||
use std::fmt::Debug; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AssumeNoRevert { | ||
/// The call depth at which the cheatcode was added. | ||
pub depth: u64, | ||
} | ||
|
||
impl Cheatcode for assumeCall { | ||
fn apply(&self, _state: &mut Cheatcodes) -> Result { | ||
let Self { condition } = self; | ||
if *condition { | ||
Ok(Default::default()) | ||
} else { | ||
Err(Error::from(MAGIC_ASSUME)) | ||
} | ||
} | ||
} | ||
|
||
impl Cheatcode for assumeNoRevertCall { | ||
fn apply_stateful<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result { | ||
ccx.state.assume_no_revert = | ||
Some(AssumeNoRevert { depth: ccx.ecx.journaled_state.depth() }); | ||
Ok(Default::default()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.