Skip to content

Instantly share code, notes, and snippets.

@AndyWatt83
Last active November 26, 2020 15:46
Show Gist options
  • Save AndyWatt83/f00bef04c525f825061ea94c38670585 to your computer and use it in GitHub Desktop.
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.
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