This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const advanceBlockAtTime = (time) => { | |
return new Promise((resolve, reject) => { | |
web3.currentProvider.send( | |
{ | |
jsonrpc: "2.0", | |
method: "evm_mine", | |
params: [time], | |
id: new Date().getTime(), | |
}, | |
(err, _) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"jsonrpc": "2.0", | |
"method": "evm_mine", | |
"params": ["NUMBER_OF_SECONDS"], | |
"id": 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("when the stream did start but not end", function() { | |
beforeEach(async function() { | |
await advanceBlockAtTime( | |
now | |
.plus(STANDARD_TIME_OFFSET) | |
.plus(5) | |
.toNumber(), | |
); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t0 1565455128964 | |
Call to sablier.withdraw took 115.92673601210117 milliseconds. | |
1) makes the withdrawal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Not what you want | |
advanceTimeAndBlock = async (time) => { | |
await advanceTime(time) | |
await advanceBlock() | |
return Promise.resolve(web3.eth.getBlock('latest')) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let snapshot; | |
let snapshotId; | |
before(async () => { | |
snapshot = await takeSnapshot(); | |
snapshotId = snapshot.result; | |
}); | |
after(async () => { | |
await revertToSnapshot(snapshotId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
takeSnapshot = async () => { | |
return new Promise((resolve, reject) => { | |
web3.currentProvider.send( | |
{ | |
jsonrpc: "2.0", | |
method: "evm_snapshot", | |
id: new Date().getTime(), | |
}, | |
(err, snapshotId) => { | |
if (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
balance.should.bignumber.satisfy(function(num) { | |
return ( | |
num.isEqualTo(newBalance.minus(amount)) || num.isEqualTo(newBalance.minus(amount).plus(ONE_UNIT)) | |
); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("when the stream did start but not end", function() { | |
const amount = new BigNumber(5).multipliedBy(1e18).toString(10); | |
beforeEach(async function() { | |
await web3.utils.advanceBlockAtTime( | |
now | |
.plus(STANDARD_TIME_OFFSET) | |
.plus(5) | |
.toNumber(), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Config { | |
_deepCopy: [ 'compilers' ], | |
_values: | |
{ truffle_directory: | |
'/Users/paulrberg/Projects/Sablier/Sablier/packages/payroll/node_modules/truffle', | |
working_directory: '/Users/paulrberg/Projects/Sablier/Sablier/packages/payroll', | |
network: 'development', | |
networks: | |
{ development: [Object], | |
kovan: [Object], |