-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
False negatives in property-based tests #4318
Comments
Came across this issue, by deafault I've seen foundry tends to use addresses of contracts defined in the setUp() function as msg.sender in invariant testing. As a workaround I've been excluding them with the excludeSender() function. |
+1 on this issue. |
For the sake of history, our recent Twitter discussion about this issue (check the different threads). |
@pcaversaccio there is a fix in that could help #7595 basically if you use |
Yup, that helps indeed. I recently get a lot of Any Idea how to prevent this in a smart way (usually rerunning fixes it, but it's annoying tbh) |
yeah, is same issue with failures described in #7497 (comment) I managed to reproduce locally by creating a failures file with the counterexample from GH action log you pointed (that is containing single line |
@pcaversaccio can this one be closed now? |
Yes. |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (b454567 2023-02-06T00:29:35.2383332Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
I realised that within a forge test run, sometimes addresses are fuzzed which are very unfortunate choices and it's getting complicated to always
assume
the right params. In order to reproduce what I exactly mean, let's have a look at the following run: https://github.com/pcaversaccio/snekmate/actions/runs/4134068222/jobs/7144742870This one fails with the following error:
So the problem here is the input address
0x2e234DAe75C793f67A35089C9d99245E1C58470b
is unfortunately the same as theerc721ReceiverMock
I create in the test:After re-running the test everything passes as intended: https://github.com/pcaversaccio/snekmate/actions/runs/4134068222.
Also, I started using things like the following since sometimes it fuzzes also the test contracts etc.:
My question I would like to discuss is, whether other face similar problems & what can be done to fine-tune it. For instance, having a sort of modifier that ensures that any fuzzed addresses within a test function should not equal any created contract addresses within the test function would already help a lot.
The text was updated successfully, but these errors were encountered: