Skip to content

Instantly share code, notes, and snippets.

@nakajo2011
Last active July 7, 2020 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakajo2011/2d45cef2cec971987f2a63db1fceae48 to your computer and use it in GitHub Desktop.
Save nakajo2011/2d45cef2cec971987f2a63db1fceae48 to your computer and use it in GitHub Desktop.
miner.stop test, but it happen error.
it('multi transfer in same block', async () => {
web3.extend({property: 'mine', methods: [{ name: 'start', call: 'miner_start', params:0}]})
web3.extend({property: 'mine', methods: [{ name: 'stop', call: 'miner_stop', params:0}]})
const instance = await MyERC20Token.new()
const beforeBlock = await web3.eth.getBlockNumber()
await web3.mine.stop()
// queued tx1
await instance.transfer(accounts[1], 100)
// queued tx2
await instance.transfer(accounts[2], 100)
await web3.mine.start()
const afterBlock = await web3.eth.getBlockNumber();
assert.equal(beforeBlock+1, afterBlock) // block increase just +1.
assert.equal(await Instance.balanceOf(accounts[1]), 100)
assert.equal(await Instance.balanceOf(accounts[2]), 100)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment