Last active
November 26, 2020 15:46
-
-
Save AndyWatt83/f00bef04c525f825061ea94c38670585 to your computer and use it in GitHub Desktop.
Shows how the evm_mine, and evm_increaseTime helper wrappers are used in an actual test.
This file contains 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 helper = require("./helpers/truffleTestHelper"); | |
describe("Testing Helper Functions", () => { | |
it("should advance the blockchain forward a block", async () =>{ | |
const originalBlockHash = web3.eth.getBlock('latest').hash; | |
let newBlockHash = web3.eth.getBlock('latest').hash; | |
newBlockHash = await helper.advanceBlock(); | |
assert.notEqual(originalBlockHash, newBlockHash); | |
}); | |
it("should be able to advance time and block together", async () => { | |
const advancement = 600; | |
const originalBlock = web3.eth.getBlock('latest'); | |
const newBlock = await helper.advanceTimeAndBlock(advancement); | |
const timeDiff = newBlock.timestamp - originalBlock.timestamp; | |
assert.isTrue(timeDiff >= advancement); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment