Skip to content

Instantly share code, notes, and snippets.

@CinnamonGrrrl
Created March 27, 2018 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CinnamonGrrrl/74d8aa9daf76402afa467de0457bac93 to your computer and use it in GitHub Desktop.
Save CinnamonGrrrl/74d8aa9daf76402afa467de0457bac93 to your computer and use it in GitHub Desktop.
// source: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/test/helpers/increaseTime.js
module.exports.increaseTime = function increaseTime(duration) {
const id = Date.now();
return new Promise((resolve, reject) => {
web3.currentProvider.sendAsync(
{
jsonrpc: "2.0",
method: "evm_increaseTime",
params: [duration],
id: id
},
err1 => {
if (err1) return reject(err1);
web3.currentProvider.sendAsync(
{
jsonrpc: "2.0",
method: "evm_mine",
id: id + 1
},
(err2, res) => {
return err2 ? reject(err2) : resolve(res);
}
);
}
);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment