'Stop the time within the test in Hardhat (Solidity)

Is it possible to stop the time within the test, until the time is changed manually via "evm_increaseTime" in Hardhat? For example when we increase time by 1 second:

await ethers.provider.send('evm_increaseTime', [1]);
await ethers.provider.send('evm_mine');

After that we somehow stop the time within the test. Has anybody had similar problem or know the solution to that?



Solution 1:[1]

It's possible. You need to set the automine mode to false:

await ethers.provider.send("evm_setAutomine", [false]);

This stops your local blockchain from mining blocks and increasing time automatically after every transaction.

ref. https://hardhat.org/hardhat-network/reference/#evm-setautomine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RiccardoS