-
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(forge): exclude certain contracts from being eavesdropped on by vm.expectRevert
#4762
Comments
I offer a $200 bounty for implementing this feature. DM me on Telegram once you have the PR. |
I think this needs to be spec'd out before a PR is opened :) First it's worth noting this concept can apply to all Then there are a lot of questions about the behavior/UX/syntax:
|
Another idea is a cheat to enable disable |
All good points/ questions, thanks @mds1.
No. The contracts meant to be excluded are (at least in my projects) dummy testing contracts that are never meant to be tested, for anything.
That + a single address would be a good starting point.
This is an optimization we can consider in future iterations of the feature/ PR.
Sounds great!
All calls, as per my explanation in two paragraphs above.
Additive, yes. Two final notes:
|
As evidenced by this StackExchange Q&A, people keep bumping into hard-to-debug scenarios that could be prevented with a feature that would allow users to exclude certain contracts from being eavesdropped by |
Thanks for mentioning the issue here @PaulRBerg. |
I think this would be the best solution. |
Supportive, also on this note
|
@PaulRBerg would proposed cheatcodes here #5299 (comment) accomplish desired behavior? thank you! |
@grandizzy I don't think they would. From Matt's code:
I would like the test to not fail if the revert address does not match. This is what I mean by excluding certain contracts from being eavesdropped. |
@PaulRBerg I actually think it helps, tested the following scenario using PR #8770 for 2 contracts like contract CounterWithoutRevert {
uint256 public number;
function count() public {
number += 1;
}
}
contract CounterWithRevert {
error RandomError();
uint256 public number;
function count() public pure {
revert RandomError();
}
} a test as function test_count_with_revert() public {
CounterWithoutRevert countNoRevert = new CounterWithoutRevert();
CounterWithRevert countRevert = new CounterWithRevert();
vm.expectRevert(address(countRevert));
countNoRevert.count();
countNoRevert.count();
countNoRevert.count();
countRevert.count();
} it's a pass. That is because when reverter address is specified |
This wasn't clear from Matt's comment. Or I might have misunderstood it. Anyway, in this case, yes this new feature accomplishes the desired behavior. Thank you! |
@grandizzy Has this always been the case for expextRevert or is that new to this version? I thought, like other |
@mds1 that's only with PR #8770 in review and with cheatcodes specifying reverter addresses as per #5299 (comment) in order to satisfy bubbling reverts.
That still holds true but it should be read as |
Does that mean the next top level to function test_count_with_revert() public {
CounterWithoutRevert countNoRevert = new CounterWithoutRevert();
CounterWithRevert countRevert = new CounterWithRevert();
vm.expectRevert(address(countRevert));
countNoRevert.count(); // If this call makes a subcall to `countRevert` and it doesn't revert, does test fail?
countNoRevert.count();
countNoRevert.count();
countRevert.count();
} I think that nuance is why I'd prefer I know this doesn't meet @PaulRBerg requirements, but the use case of the feature was really just to skip listening for reverts from staticcalls, and that same feature would also apply to events as well. So I don't think this proposed behavior of " |
yes, that's correct, in this case the test will fail right away
Agree, open to suggestions if that's not desired behavior, maybe let's move convo in PR #8770? |
Sounds good, will move my thoughts there now |
Component
Forge
Describe the feature you would like
Take the following test:
The test does not pass because Forge expects a revert in the
defaults.assets()
call, which precedes theproxy.execute
call. The catch is thatdefaults
is a testing-only contract containing default values used throughout the tests.This has to be a contract (rather than a library) because I need to calculate certain values dynamically in the constructor.
I know I could easily address the problem in my code above by flipping the order of operations. Still, I wanted to open this issue to suggest a feature to improve the developer experience when this scenario occurs.
It would be nice to have the ability to exclude certain contracts from being eavesdropped on by
vm.expectRevert
. This functionality would be analogous toexcludeContract
for invariants.The text was updated successfully, but these errors were encountered: