-
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
): add vm.expectMockCall
to enforce that a mocked function is called with certain arguments
#5480
Comments
You might be interested in |
adding a mock+expect combination in forge-std makes sense to me |
Thanks, that makes sense to me too. I won't make any changes to the std lib right now, but I'm working on some code-gen stuff that might be useful for others once it is done to assist with mocking. |
Also FYI - my codegen work will allow mocking of internal functions without needing to move the the REVM as mentioned in this PR - #432 . Like I say, I'll definitely share my work on that in the coming weeks/months 👍 |
@brockelmore Perhaps we should transfer this to Forge Std as well? Or maybe just close it and open up a new issue? Wdyt? |
Per #3782, I'm going to move this back to the foundry repo I'm also not too clear on the exact proposal here, I'd be curious to see sample code of that the cheat/UX would look like |
cheatcodes
): add vm.expectMockCall
to enforce that a mocked function is called with certain arguments
Component
Forge
Describe the feature you would like
Currently tests don't break if a mocked function is called with different arguments to what was expected.
Currently for example:
With the above code it will return 6 if the function is called with an argument of 5 or anything else, additionally it won't fail if it isn't called with 5 (which is something you sometimes want to check.
I propose adding a function called something like
mockCallStrict
to the cheats so that tests can be more strict about this.Additional context
This is a feature of Smock: https://smock.readthedocs.io/en/latest/fakes.html#asserting-call-arguments
The text was updated successfully, but these errors were encountered: