Ethereiun Solidity Contract - before hook problem

Viewed 456

The packages that I used were:

    "ganache-cli": "^6.10.0-beta.2",
    "mocha": "^8.0.1",
    "solc": "^0.6.11",
    "web3": "^1.0.0-beta.26",
    "yargs": "^13.0.0-candidate.0"

My code was:

const assert = require("assert");
const ganache = require("ganache-cli");
const Web3 = require("web3");

const web3 = new Web3(ganache.provider());

beforeEach(async () => {
  try {
    let fetchedAccounts = await web3.eth.getAccounts();
    console.log(fetchedAccounts);
  } catch (err) {
    console.log(err);
  }
});

describe("Inbox", () => {
  it("deploys a contract", () => {});
});

And the error was

this showed the contracts in console but this error also came with it

    > inbox@1.0.0 test /home/akshat/programing/inbox
    > mocha test/Inbox.test.js
      Inbox
        1) "before each" hook for "deploys a contract"
    
      0 passing (34ms)
      1 failing
    
      1) "before each" hook for "deploys a contract":
         Uncaught Error: Callback was already called.
          at /home/akshat/programing/inbox/node_modules/ganache-cli/build/ganache-core.node.cli.js:17:276
          at s.<anonymous> (node_modules/ganache-cli/build/ganache-core.node.cli.js:17:2238)
          at s.destroy (node_modules/ganache-cli/build/ganache-core.node.cli.js:37:712615)
          at finish (_stream_writable.js:658:14)
          at processTicksAndRejections (internal/process/task_queues.js:84:21)
    (node:18838) UnhandledPromiseRejectionWarning: Error: done() called multiple times in hook <"before each" hook for "deploys a contract"> (of root suite)
        at createMultipleDoneError (/home/akshat/programing/inbox/node_modules/mocha/lib/errors.js:294:13)
        at multiple (/home/akshat/programing/inbox/node_modules/mocha/lib/runnable.js:281:24)
        at done (/home/akshat/programing/inbox/node_modules/mocha/lib/runnable.js:292:14)
        at /home/akshat/programing/inbox/node_modules/mocha/lib/runnable.js:362:11
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:18838) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:18838) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! inbox@1.0.0 test: `mocha test/Inbox.test.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the inbox@1.0.0 test script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/akshat/.npm/_logs/2020-07-27T12_05_30_431Z-debug.log
0 Answers
Related