You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
597 B
23 lines
597 B
// Increases testrpc time by the passed duration (a moment.js instance)
|
|
export default function increaseTime(duration) {
|
|
const id = Date.now()
|
|
|
|
return new Promise((resolve, reject) => {
|
|
web3.currentProvider.sendAsync({
|
|
jsonrpc: '2.0',
|
|
method: 'evm_increaseTime',
|
|
params: [duration.asSeconds()],
|
|
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)
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|