You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
calling evm_setTime fails when using web3.currentProvider.send
Expected Behavior
Calling evm_setTime with anything that can be cast into a JS date should set the blockchain time
Current Behavior
Calling evm_setTime with anything that can be cast into a JS date returns an exception through the JSONRPC response (eg { error: { message: 'e.getTime() is not a function' .... })
Possible Solution
It can be worked around by editing the mangled file (ganache-core.node.cli.js) to replace p.prototype.evm_setTime=function(e,t){t(null,this.state.blockchain.setTime(e))} with p.prototype.evm_setTime=function(e,t){t(null,this.state.blockchain.setTime(new Date(e)))}
Apparently the original code was added here: cec7362 but it's out of this repo now
Since the input is passed through JSONRPC, it can be either Number/String but not a Date. I tried passing a timestamp number too, same error.
Steps to Reproduce (for bugs)
Using this code to call into a ganache-cli over network:
asyncfunctionsetTime(web3,time){// Doesn't work cause of a ganache bug: `e.getTime is not a function` cause it doesn't construct a date from the JSONRPC inputreturnnewPromise(function(resolve,reject){web3.currentProvider.send({jsonrpc: '2.0',method: 'evm_setTime',params: [newDate(time*1000)],id: 0},(err,res)=>(err ? reject(err) : (res.error ? reject(res.error) : resolve(res))))})}
The result is the following exception:
e.getTime() is not a function
This message comes through from JSONRPC (through the res.error that's returned from ganache)
Context
Trying to move the blockchain time backwards during testing. evm_increaseTime does not help here since a specific time is hardcoded into the contract
calling
evm_setTime
fails when usingweb3.currentProvider.send
Expected Behavior
Calling
evm_setTime
with anything that can be cast into a JS date should set the blockchain timeCurrent Behavior
Calling
evm_setTime
with anything that can be cast into a JS date returns an exception through the JSONRPC response (eg{ error: { message: 'e.getTime() is not a function' .... }
)Possible Solution
It can be worked around by editing the mangled file (
ganache-core.node.cli.js
) to replacep.prototype.evm_setTime=function(e,t){t(null,this.state.blockchain.setTime(e))}
withp.prototype.evm_setTime=function(e,t){t(null,this.state.blockchain.setTime(new Date(e)))}
Apparently the original code was added here: cec7362 but it's out of this repo now
Since the input is passed through JSONRPC, it can be either Number/String but not a Date. I tried passing a timestamp number too, same error.
Steps to Reproduce (for bugs)
Using this code to call into a ganache-cli over network:
The result is the following exception:
This message comes through from JSONRPC (through the
res.error
that's returned from ganache)Context
Trying to move the blockchain time backwards during testing.
evm_increaseTime
does not help here since a specific time is hardcoded into the contractYour Environment
Latest ganache from NPM, v6.9.1
Project: https://github.com/AdExNetwork/adex-protocol-eth/tree/new-token and namely https://github.com/AdExNetwork/adex-protocol-eth/blob/new-token/test/TestADXToken.js - notice the SupplyController test and also https://github.com/AdExNetwork/adex-protocol-eth/blob/new-token/test/index.js where
setTime
is implementedThe text was updated successfully, but these errors were encountered: