-
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
vm.canRevert()
: allow tests to revert in expected cases
#4090
Comments
Hmm, how would this work in practice—does the value of I think you're suggesting to reject the test case though? That seems ok, but I'd suggest |
Yes, I was thinking it would work like an assume. And not sure how you’re thinking about vm.assumeNoRevert, because that means “the next call should not revert”, which is the default behavior already. |
A reverting call currently leads to a test failure, unless you have |
Yeah you’re right. Just found the name vm.assumeNoRevert a bit confusing, but if you think about it, it does make sense to name it that way. |
Component
Forge
Describe the feature you would like
Often it's desirable to check properties of results, such as a new price of an AMM. However, these functions can contain error-checks and revert on certain inputs. And sometimes I want to make sure a property holds only if I actually get a result from a call and ignore the reverting cases.
An example of what this could look like is:
A current workaround is to use low-level calls or
try ... catch ...
, but these have to be set up for each function manually.An implementation of
vm.canRevert
/vm.allowRevert
could add to the counter ofvm.assume
checks to make sure that one isn't rejecting all calls.Additional context
No response
The text was updated successfully, but these errors were encountered: