How can I fix this?
See:
$ truffle console
truffle(development)> web3.eth.getBlock("latest").timestamp
> 1506694386
truffle(development)> web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [500000], id: 123})
{ id: 123, jsonrpc: '2.0', result: 500000 }
truffle(development)> web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [500000], id: 123})
{ id: 123, jsonrpc: '2.0', result: 1000000 }
When using evm_increaseTime
, the result returns a value that appends to 0, instead of adding onto the block time.
The expected result
value should be 1506694386 + 500000, but instead, it returns 0 + 500000.
Your Environment
- Version used: v4.1.3
- Operating System and version: Mac OSX
EDIT: On the suggestion of force-mining:
If I mine a block before (or even after) performing evm_increaseTime
, it does not make a difference:
$ truffle console
truffle(development)> web3.eth.getBlock("latest").timestamp
1506739091
truffle(development)> web3.currentProvider.send({jsonrpc: "2.0", method: "evm_mine", params: [], id: 0})
{ id: 0, jsonrpc: '2.0', result: [] }
truffle(development)> web3.eth.getBlock("latest").timestamp
1506739124
truffle(development)> web3.eth.getBlock("latest").timestamp
1506739124
truffle(development)> web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [500000], id: 123})
{ id: 123, jsonrpc: '2.0', result: 500000 }
truffle(development)> web3.currentProvider.send({jsonrpc: "2.0", method: "evm_mine", params: [], id: 0})
{ id: 0, jsonrpc: '2.0', result: [] }
truffle(development)> web3.currentProvider.send({jsonrpc: "2.0", method: "evm_increaseTime", params: [500000], id: 123})
{ id: 123, jsonrpc: '2.0', result: 1000000 }