My contract has an expiration date that I'd like to unit test but I don't know how to go about doing that. If I could mock the time of the contract that would be dope. Google search provided no information though.
[Ethereum] How to mock the time for solidity tests
soliditytestingtimestamp
Best Answer
As a general testing method, you can create another, debugging-only, contract descending from your production contract. This second contract can have methods to do anything--for example, to set the expiration date to
now
.If you want to mess with time specifically, TestRPC has an RPC method to fast forward time. Be warned, you'll have to integrate it into your testing harness somehow, since web3 does not come with it.