mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-03 17:34:22 +00:00
e37d3f73ff
This commit introduces a new `global.getEvmVersion()` that can be used to conditionally run tests, such as when tests rely on RPC APIs that are only available in specific evm nodes.
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
/*global contract, config, it, assert, mineAtTimestamp*/
|
|
const Expiration = require('Embark/contracts/Expiration');
|
|
const now = Math.floor(new Date().getTime()/1000.0); // Get unix epoch. The getTime method returns the time in milliseconds.
|
|
|
|
config({
|
|
contracts: {
|
|
deploy: {
|
|
"Expiration": {
|
|
args: [now + 1000]
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
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 () {
|
|
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);
|
|
}
|
|
await mineAtTimestamp(now + 1001); // sets block.timestamp to 1001
|
|
const isExpired = await Expiration.methods.isExpired().call();
|
|
assert.strictEqual(isExpired, true);
|
|
});
|
|
});
|