Insanely annoying "persisted failure reverts" in Foundry test #1959
Replies: 2 comments 14 replies
-
Hello @CH-coding-fire, Please show your invariant and handler file. |
Beta Was this translation helpful? Give feedback.
-
Happy 2025 @CH-coding-fire , This issue stems from Foundry's Replaying Failures feature. According to the Foundry Book, this feature is designed to incrementally replay the last test run failures by persisting them to disk. The intention is to ensure any previously encountered failures are prioritized in subsequent test runs, helping identify and fix regressions more efficiently. However, this behavior can sometimes feel "annoying" during development, especially if you're not expecting it. Here's a breakdown of how it works: How Replaying Failures Works
How to Avoid Persisted FailuresCurrently, the only way to avoid replaying failures is to manually run the following command before running your test(s): forge clean This clears the cache and prevents Foundry from replaying previously recorded failures. Possible ImprovementsIt might be helpful for the Foundry team to introduce a configuration option in Final ThoughtsWhile this feature is invaluable for catching regressions, it can indeed feel inconvenient in certain workflows. A toggle or more control over this behavior in |
Beta Was this translation helpful? Give feedback.
-
The behavior is, when "forge test --match-test invariant_mustHaveMoreValueThanTotalSupply123", then it tells me
[FAIL. Reason: revert: ERC20: insufficient allowance]
This is OKIf I do the same command as above, it tells me:
[FAIL. Reason: invariant_mustHaveMoreValueThanTotalSupply123 persisted failure revert]
This is CONFUSING as FKI am stuck on this for HOURS. Because I was not aware of the above, that is the repeated failure will cause "persisted failure revert", I googled and ChatGPT but found NOTHING, why is that????? How should a good programmer approach this problem? Also from common sense, why don't it just tell me again
[FAIL. Reason: revert: ERC20: insufficient allowance]
, like I think most programming tools do so there is consistencyBeta Was this translation helpful? Give feedback.
All reactions