0

While testing a time-dependent smart contract with truffle, I tried to use openzeppelin test-helpers' increaseTo function to forward time.

I required the dependency as shown below,

const { time } = require('@openzeppelin/test-helpers');

And added the following lines to the code.

let duration = time.duration.seconds(90500);
let latest_time = time.latest();
const timeAdvance = web3.utils.toBN(currenBlockTS).add(latest_time)
await time.increaseTo(timeAdvance);

When I ran the test, I got the following errors,

Error: The method evm_increaseTime does not exist/is not available at WebsocketSubprovider._handleSocketMessage (node_modules@trufflesuite\web3-provider-engine\subproviders\websocket.js:121:18) at WebSocket.onMessage (node_modules\ws\lib\event-target.js:120:16) at WebSocket.emit (node:events:527:28) at Receiver.receiverOnMessage (node_modules\ws\lib\websocket.js:720:20) at Receiver.emit (node:events:527:28) at Receiver.dataMessage (node_modules\ws\lib\receiver.js:414:14) at C:\Users\User\Documents\blockchain\jb_lottery\node_modules\ws\lib\receiver.js:371:23 at C:\Users\User\Documents\blockchain\jb_lottery\node_modules\ws\lib\permessage-deflate.js:307:9 at C:\Users\User\Documents\blockchain\jb_lottery\node_modules\ws\lib\permessage-deflate.js:389:7 at afterWrite (node:internal/streams/writable:497:5) at onwrite (node:internal/streams/writable:477:7) at Zlib.cb (node:internal/streams/transform:202:7) at Zlib.processCallback (node:zlib:611:8)

Error: json: cannot unmarshal number into Go struct field params.fromBlock of type string at WebsocketSubprovider._handleSocketMessage (node_modules@trufflesuite\web3-provider-engine\subproviders\websocket.js:121:18) at WebSocket.onMessage (node_modules\ws\lib\event-target.js:120:16) at WebSocket.emit (node:events:527:28) at Receiver.receiverOnMessage (node_modules\ws\lib\websocket.js:720:20) at Receiver.emit (node:events:527:28) at Receiver.dataMessage (node_modules\ws\lib\receiver.js:414:14) at C:\Users\User\Documents\blockchain\jb_lottery\node_modules\ws\lib\receiver.js:371:23 at C:\Users\User\Documents\blockchain\jb_lottery\node_modules\ws\lib\permessage-deflate.js:307:9 at C:\Users\User\Documents\blockchain\jb_lottery\node_modules\ws\lib\permessage-deflate.js:389:7 at afterWrite (node:internal/streams/writable:497:5) at onwrite (node:internal/streams/writable:477:7) at Zlib.cb (node:internal/streams/transform:202:7) at Zlib.processCallback (node:zlib:611:8)

The network used is the rinkeby test network.

3
  • The method evm_increaseTime is available in testing clients like ganache.
    – Ismael
    Jul 30 at 4:40
  • Really! is there a way to test time-dependent smart contracts on rinkeby?
    – Chukwujike
    Jul 30 at 18:01
  • One option is to use fork with ganache, see this question ethereum.stackexchange.com/questions/103184/….
    – Ismael
    Aug 1 at 5:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.