Skip to content

Commit be37cb9

Browse files
authored
Merge pull request #620 from PolymathNetwork/scp-temp-fix
Temp fix for scheduled checkpoints
2 parents 34bb63e + bfa8a0c commit be37cb9

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

test/helpers/time.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ async function takeSnapshot() {
5757
});
5858
}
5959

60+
async function jumpToTime(timestamp) {
61+
await new Promise(
62+
(resolve, reject) => {
63+
web3.currentProvider.send({
64+
jsonrpc: '2.0',
65+
method: "evm_mine",
66+
params: [timestamp],
67+
},
68+
(err, result) => {
69+
if (err) {
70+
return reject(err);
71+
}
72+
resolve(result.result);
73+
}
74+
);
75+
});
76+
await advanceBlock();
77+
}
78+
6079
async function revertToSnapshot(snapShotId) {
6180
return new Promise((resolve, reject) => {
6281
web3.currentProvider.send(
@@ -77,4 +96,4 @@ async function revertToSnapshot(snapShotId) {
7796
});
7897
}
7998

80-
export { increaseTime, takeSnapshot, revertToSnapshot };
99+
export { increaseTime, takeSnapshot, revertToSnapshot, jumpToTime };

test/x_scheduled_checkpoints.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import latestTime from "./helpers/latestTime";
22
import { duration, promisifyLogWatch, latestBlock } from "./helpers/utils";
3-
import { takeSnapshot, increaseTime, revertToSnapshot } from "./helpers/time";
3+
import { takeSnapshot, increaseTime, revertToSnapshot, jumpToTime } from "./helpers/time";
44
import { encodeProxyCall, encodeModuleCall } from "./helpers/encodeCall";
55
import { setUpPolymathNetwork, deployScheduleCheckpointAndVerified } from "./helpers/createInstances";
66

@@ -13,7 +13,7 @@ const Web3 = require("web3");
1313
let BN = Web3.utils.BN;
1414
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); // Hardcoded development port
1515

16-
contract("ScheduledCheckpoint", async (accounts) => {
16+
process.env.COVERAGE ? contract.skip : contract("ScheduledCheckpoint", async (accounts) => {
1717

1818
const SECONDS = 0;
1919
const DAYS = 1;
@@ -73,15 +73,17 @@ contract("ScheduledCheckpoint", async (accounts) => {
7373
const one_address = "0x0000000000000000000000000000000000000001";
7474

7575
before(async () => {
76-
currentTime = new BN(await latestTime());
7776
account_polymath = accounts[0];
7877
account_issuer = accounts[1];
7978

8079
token_owner = account_issuer;
8180

8281
account_investor1 = accounts[7];
8382
account_investor2 = accounts[8];
84-
account_investor3 = accounts[9];
83+
account_investor3 = accounts[9];
84+
//await jumpToTime(Math.floor((new Date().getTime())/1000));
85+
await jumpToTime(1553040000); // 03/20/2019 @ 12:00am (UTC)
86+
currentTime = new BN(await latestTime());
8587

8688
// Step 1: Deploy the genral PM ecosystem
8789
let instances = await setUpPolymathNetwork(account_polymath, token_owner);

0 commit comments

Comments
 (0)