I'm working on a revenue distribution contract that lumps eth by week. In order to test it, I need some way to set the now variable. Is there any way to do that?

Using solidity/geth.

2 Answers 2


Use ethersim to test your contract. With ethersim you can jump in time by calling the time()-function.



Make a function to get now and make its behaviour dependent on configuration which you make default to the real now in production and in an automated test you specify the now in your test fixture.

  • That should work but im hoping for a better alternative. I dont want unecessary test code in my production contracts.
    – Akhil F
    May 25, 2016 at 11:44

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.