I'm using hardhat and I added a task to manipulate time in the hardhat.config.js
file which is working fine.
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-truffle5");
const { time } = require('@openzeppelin/test-helpers');
task("increaseDays", "Increase days to currentTime")
.addParam("days", "The number of days").setAction(
async (taskArguments) => {
await time.increase(time.duration.days(Number(taskArguments.days)));
const newTime = await time.latest();
console.log('New Time is:', newTime.toString(), new Date(newTime.toString() * 1000));
return newTime.toString();
});
....
....
The Problem now is that every test script that implements const { time } = require('@openzeppelin/test-helpers');
fails directly when I try to run npx hardhat test --network hardhat ./test/script-test.js
"before all" hook for "should revert on fallback and receiver function":
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (node_modules\web3-core-helpers\lib\errors.js:43:16)
at XMLHttpRequest.request.onreadystatechange (node_modules\web3-providers-http\lib\index.js:95:32)
at XMLHttpRequestEventTarget.dispatchEvent (node_modules\xhr2-cookies\xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (node_modules\xhr2-cookies\xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpRequestError (node_modules\xhr2-cookies\xml-http-request.ts:379:8)
at ClientRequest.<anonymous> (node_modules\xhr2-cookies\xml-http-request.ts:266:37)
at Socket.socketErrorListener (_http_client.js:406:9)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
The test-script
const { expect } = require('chai');
const { time } = require('@openzeppelin/test-helpers');
describe('Test Contract', () => {
before(async () => {
const startTime = BigNumber.from((await time.latest()).toString());
});
it('should revert on fallback and receiver function..', () => {
expect(true).to.true;
});
});
I'm using "hardhat": "^2.3.0" and "@openzeppelin/test-helpers": "^0.5.11". Any idea what is the problem and how could I solve it?
script-test.js
?