1.1.0 • Published 5 years ago

sol-time-machine v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

sol-time-machine

Block manager for Solidity tests

Install

npm install sol-time-machine

Usage

const TimeMachine = require('sol-time-machine')
const timeMachine = new TimeMachine(global.web3)

snapshot/revert

// test.js
contract('Example', (accounts) => {
  beforeEach(async () => {
    await timeMachine.snapshot()
  })
  
  afterEach(async () => {
    await timeMachine.revert()
  })

  // Your tests here...
})

mine

// advance 10 blocks
await timeMachine.mine(10)

mineTo

// advance to block number 10
await timeMachine.mineTo(10)