How to use timekeeper - 10 common examples

To help you get started, we’ve selected a few timekeeper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SetProtocol / setprotocol.js / test / integration / api / MACOManagerAPI.spec.ts View on Github external
beforeEach(async () => {
        // Elapse the rebalance interval
        await increaseChainTimeAsync(web3, ONE_DAY_IN_SECONDS);

        await updateMedianizerPriceAsync(
          web3,
          ethMedianizer,
          initialMedianizerEthPrice.div(10),
          SetTestUtils.generateTimestamp(1000),
        );

        // Free time at the rebalance interval minimum
        timeKeeper.freeze(nextRebalanceAvailableInSeconds.toNumber() * 1000);
      });
github SetProtocol / setprotocol.js / test / integration / api / SocialTradingAPI.spec.ts View on Github external
transferProxy.address,
        UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
        { from: subjectCaller }
      );

      const tradingPoolAddress = extractNewSetTokenAddressFromLogs(formattedLogs);
      const tradingPoolInstance = await RebalancingSetTokenV2Contract.at(
        tradingPoolAddress,
        web3,
        TX_DEFAULTS
      );

      // Fast forward to allow propose to be called
      const lastRebalancedTimestampSeconds = await tradingPoolInstance.lastRebalanceTimestamp.callAsync();
      nextRebalanceAvailableAtSeconds = lastRebalancedTimestampSeconds.toNumber() + rebalanceInterval.toNumber();
      timeKeeper.freeze(nextRebalanceAvailableAtSeconds * 1000);
      increaseChainTimeAsync(web3, rebalanceInterval.add(1));

      subjectManager = setManager.address;
      subjectTradingPool = tradingPoolAddress;
      subjectNewAllocation = ether(.75);
      subjectLiquidatorData = SetUtils.stringToBytes('');

      await core.issue.sendTransactionAsync(collateralAddress, ether(2), { from: subjectCaller });
      await core.issue.sendTransactionAsync(subjectTradingPool, ether(2), { from: subjectCaller });
    });
github uber-archive / idl / test / idl.js View on Github external
return function corrupt(callback) {
        tk.freeze(new Date(time));
        var metaPath = path.join(cluster.localApp, 'idl', 'meta.json');
        fs.readFile(metaPath, 'utf8', onRawMetaJson);

        function onRawMetaJson(err, rawJson) {
            if (err) {
                return callback(err);
            }
            var lines = rawJson.split('\n');
            rawJson = lines.slice(0, lines.length - 2).join('\n');
            fs.writeFile(metaPath, rawJson, 'utf8', callback);
        }
    };
}
github uber-archive / idl / test / idl.js View on Github external
return function corrupt(callback) {
        tk.freeze(new Date(time));
        var metaPath = path.join(cluster.localApp, 'idl', 'meta.json');
        fs.readFile(metaPath, 'utf8', onRawMetaJson);

        function onRawMetaJson(err, rawJson) {
            if (err) {
                return callback(err);
            }
            var lines = rawJson.split('\n');
            rawJson = lines.slice(0, lines.length - 2).join('\n');
            fs.writeFile(metaPath, rawJson, 'utf8', callback);
        }
    };
}
github uber-archive / idl / test / idl.js View on Github external
return function fetch(callback) {
        tk.freeze(new Date(time));
        cluster.idlFetch(
            remoteId,
            inspectBoth(cluster, inspectLocal, callback)
        );
    };
}
github uber-archive / idl / test / idl.js View on Github external
return function fetch(callback) {
        tk.freeze(new Date(time));
        cluster.idlFetch(
            remoteId,
            inspectBoth(cluster, inspectLocal, callback)
        );
    };
}
github uber-archive / idl / test / idl.js View on Github external
return function publish(callback) {
        tk.freeze(new Date(time));
        cluster.idlPublish(
            path.join(cluster.remotesDir, remoteName),
            inspectBoth(cluster, inspectLocal, callback)
        );
    };
}
github uber-archive / idl / test / idl.js View on Github external
return function publish(callback) {
        tk.freeze(new Date(time));
        cluster.idlPublish(
            path.join(cluster.remotesDir, remoteName),
            inspectBoth(cluster, inspectLocal, callback)
        );
    };
}
github uber-archive / idl / test / idl.js View on Github external
return function update(callback) {
        tk.freeze(new Date(time));
        cluster.updateRemote(
            remoteName,
            fixtures,
            inspectBoth(cluster, inspectLocal, callback)
        );
    };
}
github SetProtocol / setprotocol.js / test / integration / api / RebalancingManagerAPI.spec.ts View on Github external
async function subject(): Promise {
        await increaseChainTimeAsync(web3, timeFastForward);
        timeKeeper.freeze(nextRebalanceAvailableInSeconds.toNumber() * 1000);
        return rebalancingManagerAPI.proposeAsync(
          subjectManagerType,
          subjectManagerAddress,
          subjectRebalancingSetToken,
          { from: subjectCaller },
        );
      }

timekeeper

Easy testing of time-dependent code.

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis

Popular timekeeper functions