vm.warp
changes block.timestamp
in test contract but not in contracts-under-test
#344
Open
2 tasks done
Labels
cheatcode
Issue with a cheat code against zksync
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.0.2 (532ef5e 2024-04-22T00:21:35.201114596Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
I was getting some weird behavior while testing a limit order book contract, which stores orders with an expiry timestamp, when testing for expired orders. So I set up a minimal reproducible example, and found a discrepancy between
block.timestamp
when read in the test contract (Expiry.t.sol) vs. when it is read in the contract-under-test (Expiry.sol). The contracts are as follows:The resulting logs and traces are:
Two things about the logs strike me as odd:
Expiry
,block.timestamp
is incrementing by 1 after every call from the test contract, though it does not increment in the context ofExpiryTest
.skip(1 days)
in the test contract (which callsvm.warp
under the hood),block.timestamp
is updated correctly in the context ofExpiryTest
but is unaffected in the context ofExpiry
.The expected behavior would result in the following logs instead:
Minimal reproducible example repo
Note: I am not using
via-ir
in this minimal example, though I do need to use it in the limit order repo I'm working on, because certain dependencies frommatterlabs/era-contracts
throw stack-too-deep compilation errors otherwise. I am aware of the potential issues from usingvm.warp
andblock.timestamp
with via-ir, which is (or at least was) a general issue with foundry, but this seems to be something different.The text was updated successfully, but these errors were encountered: