-
Notifications
You must be signed in to change notification settings - Fork 133
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
testing: invariants #32
Comments
After some trial and error with invariant testing the problem is that it does not seem to guarantee the invariant as we walk through all other tests in the file. Rather, it fuzzes a series of inputs (sender_address, target_address and calldata) and checks if the invariants are ever violated. This is fine for asserting that invariants hold within a single function, but there are many logical branches that can only reach when another function has been called with another parameter. Is there any way to such cases? Next step might be to write out a sample test and prove that the invariant test misses (or catches) such cases, before determining whether to integrate it into our suite. Either way, lower priority for now. Resources: |
Saw it linked and wanted to give my take.
Invariant testing does catch these kind of scenarios. But it depends on the complexity and on the probability of such events happening during the testing run. However there are certain branches that it will be very improbable to catch. See this thread for more: foundry-rs/foundry#2851 . We do have some tweaks to catch some: eg To conclude that invariant testing is still a valuable tool to add . But just like any tool, it's incomplete by itself. |
@joshieDo thanks for the details - is it possible to write invariants for map values? for instance, an invariant I want to test is |
I'm interested in picking this one up. |
Explore foundry's new invariant test model, which maple finance has implemented here.
We might be able to use this to assert invariants while fuzzing, but needs more investigation and there are no docs yet. Probably easiest to wait for a while until docs come out since we have other higher pri items right now.
The text was updated successfully, but these errors were encountered: