foundry-rs / foundry-rs/foundry
Detect use of `block.timestamp` when running `forge coverage` with `--ir-minimum` enabled
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 510
Description
### Component
Forge
### Describe the feature you would like
## Problem
`block.timestamp` is assumed to be constant when `--ir-minimum` (via IR) is enabled, and this leads to false negative failed tests when the tests use the [`warp` cheat](https://getfoundry.sh/reference/cheatcodes/warp).
This can easily create hard-to-debug circumstances - tests that normally pass start failing, and debugging via IR-enabled code is not easy.
For instance, I spent an hour debugging one of our tests.
## Solution
Detect the use of `block.timestamp` in the users' tests, and throw a bespoke warning (or error, if the user specifies so via a config field) about it. Recommend using `vm.getBlockTimestamp()` instead.
### Additional context
## Related
- https://github.com/foundry-rs/foundry/issues/6180
- https://github.com/foundry-rs/foundry/issues/10683
- https://github.com/foundry-rs/foundry/issues/3357
Contributor guide
Assessment
This issue has not been assessed yet.