trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.6k stars 676 forks source link

evm_setTime not work inside the contract #4386

Open gpmn opened 1 year ago

gpmn commented 1 year ago

My js test case call evm_setTime to update time first ,then I check the eth_getBlockByNumber and got the time correctly updated. But then I call a function of my contract, the block.timestamp inside the contract still the 'real' time.

I update the time in this way:

        await provider.send("evm_setTime", [Date.now() + 1000*60*60*(24 + 1)]) ;

then I call evm_mine then check the block timestamp in this way:

        await provider.send("evm_mine");
        console.log("after evm_mine:");
        var {number, timestamp} = await provider.send("eth_getBlockByNumber", ["latest"]);
        console.log({number, timestamp:Number(timestamp)});

The log is ok in js code. But within the contract, I got the bad block.timestamp, which is looked like not changed at all.

Any sugguestion?

davidmurdoch commented 1 year ago

What version of Ganache?