-
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
How to combine multiple supposed-to-fail contract calls in one test case? #3950
Comments
@odyslam thoughts about this? iirc we discussed multi expectRevert at some point, so maybe you have some insight here |
Actually, I just realized that by making the functions public in the Testhelper.sol contract, the test run will pick them up automatically. So I dont even need to aggregate the functions and call them explicitly. This helps me partially. But nevertheless I see benefits of having multiple reverts in one call |
@mattsse I think this is another use-case for the combinators we talked about:
|
Closing in favor of #3723 as it has a larger body of discussion |
Hey Guys,
I am coding a Testhelper.sol contract which features some standard tests that should be inherited and executed by multiple other test files. We have numerous diamond facets and we want to make sure that they all pass the same tests whilst reducing boilerplate code.
Aggregating and calling positive tests works fine.
But aggregating negative tests does not work since after the first test failed, the tx is reverted already and the following tests will never be executed.
I cannot work with try/catch here since these are internal calls.
In Hardhat I could apply the following principle:
expectRevert(testFailNegative1());
expectRevert(testFailNegative2());
...
But with foundry I have not found a way to have several reverting calls in one test case.
Do you have a suggestion for me how I could implement such a pattern?
file Testhelper.sol
file TestFacet.t.sol
The text was updated successfully, but these errors were encountered: