I have a trouble with comparing timestamp parameter(in test) and now in smart contract.
Here is my smart contract:
function create(uint created_at) public {
require(now > created_at, "The created_at should be less than now .");
}
And test function:
it("...should store the created_at", async () => {
const storageInstance = await Storage.deployed();
let created_at = new Date().getTime();//create utc now timestamp
await storageInstance.create(created_at);
}
The test doesn't pass. Error:
The created_at should be less than now .
require((now + 1 days) > created_at, "The created_at should be less than now .");
in smart contracts, the error is same. – adem caglin Mar 11 '19 at 14:11