Skip to content

Commit

Permalink
fix: use vm.getBlockTimestamp for skip and rewind (#634)
Browse files Browse the repository at this point in the history
Given that during `via-ir` compilations, the `block.timestamp` variable
might be distorted due to optimizations, the more correct way to obtain
the block timestamp. See [this
discussion](foundry-rs/foundry#1373 (comment))
  • Loading branch information
xenide authored Dec 4, 2024
1 parent 83c5d21 commit 051fb65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/StdCheats.sol
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,11 @@ abstract contract StdCheats is StdCheatsSafe {

// Skip forward or rewind time by the specified number of seconds
function skip(uint256 time) internal virtual {
vm.warp(block.timestamp + time);
vm.warp(vm.getBlockTimestamp() + time);
}

function rewind(uint256 time) internal virtual {
vm.warp(block.timestamp - time);
vm.warp(vm.getBlockTimestamp() - time);
}

// Setup a prank from an address that has some ether
Expand Down

0 comments on commit 051fb65

Please sign in to comment.