calling `evm_mine` with a `timestamp` does not persist time offset
See original GitHub issueDiscussed in https://github.com/trufflesuite/ganache/discussions/3264
I’m opening as an issue as suggested by @davidmurdoch
<div type='discussions-op-text'>Originally posted by msuscens June 21, 2022 Hello,
I have Truffle tests that successfully pass with Ganache v6 but fail with Ganache v7.3.1. The truffle tests in question use the ganache-time-traveler utility to advance time. Specifically, the issue is with functions that need a certain amount of time to pass before they will execute (without reverting). I, therefore, use ganache-time-traveler to advance the time before executing the function. Unfortunately, with ganache 7.3.1 these functions revert even though time has been advanced by the required amount. Here is an example:
describe("After Incubation: Hatch single egg", () => {
let snapshotId
beforeEach("Advance Time to End of Incubation", async() => {
let snapshot = await timeMachine.takeSnapshot()
snapshotId = snapshot['result']
// Incubate for required time
await truffleAssert.passes(
timeMachine.advanceTimeAndBlock(INCUBATION_DURATION),
"Failed to advance time and block"
)
})
afterEach("Revert To Start of Incubation Time", async() => {
await timeMachine.revertToSnapshot(snapshotId)
})
it("should allow egg owner to hatch it, emitting an Hatched event ", async () => {
let txResult
await truffleAssert.passes(
txResult = await eggToken.hatch(
[0], //eggids
{from: accounts[2]}
)
)
truffleAssert.eventEmitted(txResult, 'Hatched', (ev) => {
return equals(toNumbers(ev.hatchlingIds), [0]) &&
equals(toNumbers(ev.eggIds),[0]) &&
ev.owner == accounts[2]
}, "Event Hatched has incorrect parameter values!")
})
etc …
This test passes with Ganche v6 but eggToken.hatch
reverts under v7.3.1 with the following message:
After Incubation: Hatch single egg
should allow egg owner to hatch it, emitting an Hatched event :
Transaction: 0x20883a2a3329b9925a86499b4fe1e9727a029f197d00f084ed920e94eb1954d6 exited with an error (status 0). Reason given: hatch: Egg not incubated!.
Please check that the transaction:
- satisfies all conditions set by Solidity `require` statements.
- does not trigger a Solidity `revert` statement.
StatusError: Transaction: 0x20883a2a3329b9925a86499b4fe1e9727a029f197d00f084ed920e94eb1954d6 exited with an error (status 0). Reason given: hatch: Egg not incubated!.
at Context.<anonymous> (test/2.eggToken/6.eggToken_hatch_gen0_test.js:217:43)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I’d appreciate any help/advice on how to resolve this issue.
I’m on a 2022 MacBook Pro (M1 Pro processor): MacOS 12.4 Truffle v5.5.3 (core: 5.5.3) Ganache v7.0.1 Solidity - 0.8.13 (solc-js) Node v14.15.5 Web3.js v1.5.3
Note: Even though it says “Ganache v7.0.1” above (from ‘truffle version’), I’ve installed v7.3.1 and when I start ganache (via CL) it says “ganache v7.3.1 (@ganache/cli: 0.4.1, @ganache/core: 0.4.1)”
</div>Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
@jeffsmale90 this is an issue and not a PR, so I don’t think we should close it until the fix is merged 😄
Great find, @davidmurdoch!
@msuscens, hopefully using the
--miner.timestampIncrement 1
flag will suffice as a workaround until we get a fix released.