I have a function that requires 7 days to pass from the time of an event (lockTime) before the rest of it will execute:

function resetGame () public onlyOwner {
    require (block.timestamp >= lockTime + 7 days);

how could I write a test using JS and chai to test that when 7 days pass, the function works as intended?

(p.s. I am using Hardhart and ethers.js)

1 Answer 1


You can use evm_increaseTime rpc available in Hardhat Network (docs).

await hre.ethers.provider.send('evm_increaseTime', [7 * 24 * 60 * 60]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.