Skip to content
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): add expectPartialRevert cheatcode #8763

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

grandizzy
Copy link
Collaborator

@grandizzy grandizzy commented Aug 28, 2024

Motivation

Closes #3725
Closes #7629

vm.expectRevert(bytes4) cheatcode checks for revert data to fully match whereas only the first 4 bytes should be checked. As suggested in #3725, for backwards compatibility reasons a new vm.expectPartialRevert(bytes4) cheatcode is introduced which checks only the first 4 bytes of reverted data.

Solution

  • add ExpectedRevert.partial_match and compare only the first 4 bytes actual / expected reverts if set to true
  • add new expectPartialRevert cheatcode that sets ExpectedRevert.partial_match to true

@grandizzy grandizzy marked this pull request as ready for review August 28, 2024 06:57
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, lgtm

we need to also add this to the book and highlight how this differs from other expect calls

@grandizzy grandizzy merged commit 327e29e into foundry-rs:master Aug 28, 2024
20 checks passed
@grandizzy grandizzy deleted the issue-3725 branch August 28, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants