-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Labels
T-bugType: bugType: bugT-needs-triageType: this issue needs to be labelledType: this issue needs to be labelled
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge Version: 1.2.2-stable
Commit SHA: 73ac79f
Build Timestamp: 2025-06-01T14:56:45.336809000Z (1748789805)
Build Profile: maxperf
What version of Foundryup are you on?
foundryup: 1.0.1
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
When compiling with --via-ir
and --optimize true
instances of vm.warp()
yield unexpected results:
function test_warping() public {
uint256 startTime = block.timestamp;
uint256[8] memory timestamps = [
uint256(0),
uint256(86400),
uint256(604800),
uint256(2678400),
uint256(5184000),
uint256(15811200),
uint256(31536000),
uint256(63072000)
];
for (uint256 i = 0; i < timestamps.length; i++) {
console2.log("Warping to: ", startTime + timestamps[i]);
vm.warp(startTime + timestamps[i]);
assertEq(block.timestamp, startTime + timestamps[i], "Warping failed");
}
}
When running with forge test -vv --via-ir --optimize false --match-test test_warping
it succeeds. The tests fail with forge test -vv --via-ir --optimize true --match-test test_warping
:
[FAIL: Warping failed: 86401 != 172801] test_warping() (gas: 10223)
Logs:
Warping to: 1
Warping to: 86401
Even when removing the assertEq
, startTime + timestamps[i]
yields an incorrect result. However, removing vm.warp()
as well results in the correct logs. So it's something strange that is happening when using the vm.warp
cheatcode.
Metadata
Metadata
Assignees
Labels
T-bugType: bugType: bugT-needs-triageType: this issue needs to be labelledType: this issue needs to be labelled
Type
Projects
Status
Done