2019-11-21 04:33:31 +00:00
|
|
|
/*global contract, config, it, assert, mineAtTimestamp*/
|
2019-10-17 18:39:25 +00:00
|
|
|
const Expiration = require('Embark/contracts/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 () {
|
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);
|
|
|
|
});
|
|
|
|
});
|