-
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
Add a vm.mockCallRevert cheatcode #2740
Comments
Makes sense |
IMO if this is added we can also close foundry-rs/forge-std#46, as cheatcodes would then cover the majority of mocking use cases |
Could you mock a revert by returning |
I don't think so, because the call's |
I suppose you could make |
No, that would make the EVM unwind entirely. No way to stop that. |
I mean something like: vm.ExpectRevert(RevertReasons.OUT_OF_GAS);
(bool success, ) = target.call{ gas: 1 }(...); Where you pass a defined amount of gas to a subcall and it reverts there but there is still gas left in the higher level call to continue. This is probably a more fringe usecase so not super important |
This would still cause the EVM to unwind 😄 |
This would be very useful. |
How is the state of this? It would be very useful |
I have a working mvp here: #4343 Shall I take things forward? |
That would be awesome, thanks @reubenr0d. I'll assign this to you. I think we need two functions, one that requires value, and one that doesn't: function mockCallRevert(address, bytes calldata, bytes calldata) external;
function mockCallRevert(address, uint256, bytes calldata, bytes calldata) external; |
Component
Forge
Describe the feature you would like
I might be missing something but it seems like it's currently only possible to mock return values, but not reverts. For now, in my case I can simply create a Mock contract that does that for me but I'd imagine it could be handy to allow this via a cheatcode for convenience.
Additional context
No response
The text was updated successfully, but these errors were encountered: