3
votes

I'm getting a timeout error when I try to send the contract to Ganache. My code is as follows,

const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const {interface,bytecode} = require('../compile');

let accounts;
let inbox;

beforeEach(async() => {
accounts = await web3.eth.getAccounts();
inbox = await new web3.eth.Contract(JSON.parse(interface))
  .deploy({data: bytecode,arguments:['Hi There !'] })
  .send({from: accounts[0], gas:'1000000'});
});

describe("inbox", () => {
it('deploys a contract', () => {
    console.log(inbox);
 })
})

When I comment out the send method (provided below), the program runs without any issues. However, adding it back introduces the timeout error. No matter howmuch time I assign for mocha timeout, I still get the same error.

.send({from: accounts[0], gas:'1000000'});

There are similar posts regarding timeout such as listed below, Error: Timeout of 2000ms exceeded. For async tests and hooks. Unit test with mocha and chai

Unit test error with mocha and chai Timeout of 2000ms exceeded. For async tests and hooks

Mocha testing with promises: Error: Timeout of 2000ms exceeded

Mocha exceeding 2000ms timeout when returning a promise

None of the above solutions worked for me (mostly talking about increasing the timeout). Additionally, I downgraded web3 library as proposed in a different forum. However, it didn't work either.

You can find the exact issue posted by someone else at a different forum. Apparently, that question has not received any potential answers as well.

1
try removing the gas property and check - Sanjay S B
@SanjaySB It returns an error when the gas limit is removed (the error: base fee exceeds gas limit). - cuser
what are the solc, web3 versions - Sanjay S B
@SanjaySB solc: 0.4.26 and web3: 1.0.0-beta.55. However, as mentioned in the post, I downgraded the versions and recompiled. None of them worked. - cuser
did you try the solc version 0.4.25? - Sanjay S B

1 Answers

0
votes

I installed truffle v5.0.24 and started working on the truffle console which solved all the issues.