forked from XatMassacrE/truffle-js-test-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 1.37 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module.exports = {
assertRevert: async (promise) => {
try {
await promise
} catch (error) {
const revertFound = error.message.search('revert') >= 0
assert(revertFound, `Expected "revert", got ${error} instead`)
return
}
assert.fail('Expected revert not received')
},
addDaysOnEVM: async function(days) {
const addSeconds= 60 * 60 * 24 * days
const currentBlockTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp
await web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [addSeconds], id: 0})
await web3.currentProvider.send({jsonrpc: "2.0", method: "evm_mine", params: [], id: 0})
},
addHoursOnEVM: async function(hours) {
const addSeconds = 60 * 60 * hours
const currentBlockTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp
await web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [addSeconds], id: 0})
await web3.currentProvider.send({jsonrpc: "2.0", method: "evm_mine", params: [], id: 0})
},
addMinutesOnEVM: async function(minutes) {
const addSeconds = 60 * 60 * 24 * minutes
const currentBlockTime = web3.eth.getBlock(web3.eth.blockNumber).timestamp
await web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [addSeconds], id: 0})
await web3.currentProvider.send({jsonrpc: "2.0", method: "evm_mine", params: [], id: 0})
},
}