2020-01-24 11:04:42 +00:00
|
|
|
/*global artifacts, contract, config, it, assert, mineAtTimestamp*/
|
|
|
|
const Expiration = artifacts.require('Expiration');
|
2019-11-21 04:33:31 +00:00
|
|
|
const now = Math.floor(new Date().getTime()/1000.0); // Get unix epoch. The getTime method returns the time in milliseconds.
|
2019-10-17 18:39:25 +00:00
|
|
|
|
|
|
|
config({
|
|
|
|
contracts: {
|
|
|
|
deploy: {
|
|
|
|
"Expiration": {
|
2019-11-21 04:33:31 +00:00
|
|
|
args: [now + 1000]
|
2019-10-17 18:39:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
contract("Expiration", function() {
|
|
|
|
it("should not have expired yet", async function () {
|
|
|
|
const isExpired = await Expiration.methods.isExpired().call();
|
|
|
|
assert.strictEqual(isExpired, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should have expired after skipping time", async function () {
|
2020-01-06 14:14:10 +00:00
|
|
|
const client = await getEvmVersion();
|
|
|
|
|
|
|
|
if (client.indexOf('EthereumJS TestRPC') === -1) {
|
|
|
|
console.info(`Skipping test because it requires the use of Ganache. Current blockchain client: ${client}`);
|
|
|
|
return assert.ok(true);
|
|
|
|
}
|
2019-11-21 04:33:31 +00:00
|
|
|
await mineAtTimestamp(now + 1001); // sets block.timestamp to 1001
|
2019-10-17 18:39:25 +00:00
|
|
|
const isExpired = await Expiration.methods.isExpired().call();
|
|
|
|
assert.strictEqual(isExpired, true);
|
|
|
|
});
|
|
|
|
});
|