-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(cheatcodes
): count assertion for expectRevert
#9484
Conversation
cheatcodes
): count assertion for expectRevert
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.
Looks good to me, pending other reviews
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.
lgtm
) { | ||
if let Ok(decoded) = Vec::<u8>::abi_decode(&actual_revert[4..], false) { | ||
actual_revert = decoded; | ||
// Reverter check |
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.
this makes sense, cannot think of a cleaner way to structure code as we need to check both reverter and revert reason
Ref: foundry-rs/foundry#9484 ```solidity /// Expects `count` number of reverts from the upcoming calls with any revert data or reverter. function expectRevert(uint64 count) external; /// Expects `count` number of reverts from the upcoming calls that match the revert data. function expectRevert(bytes4 revertData, uint64 count) external; /// Expects `count` number of reverts from the upcoming calls that exactly match the revert data. function expectRevert(bytes calldata revertData, uint64 count) external; /// Expects `count` number of reverts from the upcoming calls from the reverter address. function expectRevert(address reverter, uint64 count) external; /// Expects `count` number of reverts from the upcoming calls from the reverter address that match the revert data. function expectRevert(bytes4 revertData, address reverter, uint64 count) external; /// Expects `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data. function expectRevert(bytes calldata revertData, address reverter, uint64 count) external; ```
Motivation
Closes #509
Solution
Implement
expectRevert
overloads with thecount
arg. Negative assertions can be made by settingcount
to0