-
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
Function-level assertions don't work when using invariants. #4718
Comments
@joshieDo This sounds like a bug in how we check invariant failures? Since the global failure introduced in dapphub/ds-test#30 should allow this to be supported. Also cc'ing @lucas-manuel who wrote the docs @wirew0lf in the meantime you should be able to work around this by using |
Yeah we've also noticed the same issue, using require statements across the handlers isn't desirable as we have built alot of assertion helpers to assert state across our system. We really could use this functionality! |
@mds1 pinging this issue again for visibility, would be a huge unlock for invariant testing. |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (388c3c0 2023-04-10T00:15:22.461433000Z)
What command(s) is the bug in?
forge test -m invariant
Operating System
macOS (Apple Silicon)
Describe the bug
According to the invariant testing documentation in the foundry book it is possible to use function-level assertions in a handler. However, this doesn't seem to work. Minimal working example:
Counter.sol
CounterHandler.sol
CounterInvariants
As shown in the CounterHandler contract I've introduced some assertions that should fail such as
assertTrue(false)
andassertEq(uint(0), uint(1))
. However, when running the invariant test it will succeed.The text was updated successfully, but these errors were encountered: