You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Demonstrate that tests don't work as expected with Yul * This test should fail, and does fail when run with via-ir=false. * But it succeeds when compiled with via-ir=true. */function testYul() public {
uint256 time =block.timestamp;
assertTrue(time ==1, "time is not 1 at the beginning");
console.log("stored time before: ", time);
// Problem 1: this warp changes the contents of the "time" variable, even though it shouldn't
vm.warp(2 hours);
console.log("stored time after: ", time);
// Problem 2: none of these assertions fail, even though at least one shouldassertTrue(time ==1, "time is not 1 after warp");
assertTrue(time ==2 hours, "time is not 1 after warp");
console.log("This line is executed even though it shouldn't be reachable");
}
time should always stay 1 in this test.
The test should fail because of the conflicting assertions.
Both expectations hold when compiling with via-ir=false, but neither of them holds when compiling with via-ir=true.
I found this problem when compiling my existing tests with via-ir=true for the first time. Now I am unsure how to proceed. In my opinion, this minimal example suggests some bug in foundry. Please advise on how to proceed.
I have not found any related issues.
Praise
Foundry rocks!
The text was updated successfully, but these errors were encountered:
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (e918c81 2023-06-27T00:04:31.801932823Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
Problem
time
should always stay1
in this test.Both expectations hold when compiling with
via-ir=false
, but neither of them holds when compiling withvia-ir=true
.How to reproduce
Find the demo repository and follow the README.
Additional info
I found this problem when compiling my existing tests with
via-ir=true
for the first time. Now I am unsure how to proceed. In my opinion, this minimal example suggests some bug in foundry. Please advise on how to proceed.I have not found any related issues.
Praise
Foundry rocks!
The text was updated successfully, but these errors were encountered: