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

op-chain-ops: vm.expectRevert Go support #12720

Open
protolambda opened this issue Oct 29, 2024 · 1 comment
Open

op-chain-ops: vm.expectRevert Go support #12720

protolambda opened this issue Oct 29, 2024 · 1 comment
Assignees

Comments

@protolambda
Copy link
Contributor

Request by @maurelian: support the vm.expectRevert cheatcode in the Go EVM-script environment.

Docs: https://book.getfoundry.sh/cheatcodes/expect-revert?highlight=expectRevert#expectrevert

To implement:

  • do the pattern-match of revert data:
    • expectPartialRevert: selector matched only
    • expectRevert(bytes): exact full message
    • expectRevert(bytes4): exact selector only
    • expectRevert(): any message
  • substitute the return-status of the next sub-call that matches the revert or not. Similar to how we set up a prank, we need to remember an expected-revert in the call-frame, to then apply it as we bubble back the revert.
    • There might be a way to change the return-status in the existing tracer. Otherwise we may need a new but simple geth hook, similar to the caller-override.
@protolambda protolambda self-assigned this Oct 29, 2024
@mds1
Copy link
Contributor

mds1 commented Oct 29, 2024

One note is that expectRevert in forge has a giant footgun in that it's intended to only work on the next CALL, but by accident it also works on code at the same call depth as the test (e.g. JUMPs to a function), but only for the first one in a test, and the rest of the test silently does not execute. Example + more info in this issue: foundry-rs/foundry#3437 (comment)

Everyone has come to rely on this bug in expectRevert so it has not been removed yet. Regardless, let's take the stricter approach here and only support expectRevert on CALLs, which is the ideal foundry v1 fix since that is how all other expect* cheats work: foundry-rs/foundry#7238

@maurelian maurelian mentioned this issue Oct 30, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants