-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add vm.assume
cheatcode
#240
Conversation
tracing::debug!("!!! FORCING REVERT"); | ||
tracing::debug!(?error, pc, "Forcing revert"); | ||
|
||
self.return_data = Some(error.reason); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.to_return_data()
takes care of encoding. Probably that's why you are having padding issues and cannot exact match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! error
is of type ForceRevertError
(see below). In the impl there's option to instantiate using abi encoding or just the raw bytes. In the case of this PR we use ForceRevertError::raw
given we don't want the abi encoding to return the string. But since the revert reason (same as return data) is a Vec<U256>
it will inevitably still have padding.
#[derive(Debug, Clone)]
struct ForceRevertError {
reason: Vec<U256>,
}
impl ForceRevertError {
fn abi_encode(reason: Vec<u8>) -> Self {
Self { reason: reason.to_return_data() }
}
fn raw(reason: Vec<u8>) -> Self {
Self { reason: reason.chunks(32).map(U256::from_big_endian).collect_vec() }
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But don't we actually want the abi encoded reason. I can't think of anything in solidity that isn't abi encoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit c3cd15d
What π»
vm.assume
cheatcode, that allows for skipping fuzz test runs when a given condition is not met.Why β
Evidence π·