Async error while running Ethereum Smart Contracts tests ?

Plugin Development
  • Hello ,
    I˙m having issues with running some ethereum smart contracts tests in Mocha. Im trying to deploy a contract using async. I inquired about this issue in the Mocha.js section and was informed that the nature of the error is with async.

    My node.js version is 6.14.5
    My async version is 2.6.2

    My Inbox.test.js:


    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 ()=> {
    //get a a list of all accounts
    	accounts = await  web3.eth.getAccounts();
    // Use one of those accounts to deploy the contract
    	inbox =  await new   web3.eth.Contract(JSON.parse(interface))
    	.deploy({ data: bytecode, arguments: ["Hi there!"] })
    	.send({ from: accounts[0], gas: "1000000" });
    describe ("Inboxxx", () => {
    	it("this deploys a contract", () => {

    My package.json:

      "name": "inbox",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "mocha"
      "author": "",
      "license": "ISC",
      "dependencies": {
       "async": "^2.6.2",
        "ganache-cli": "^6.0.3",
        "mocha": "^4.0.1",
        "save": "^2.4.0",
        "solc": "^0.4.19",
        "web3": "^1.0.0-beta.26"

    My compile.js

    const path = require("path");
    const fs = require("fs");
    const solc = require("solc")
    const inboxPath = path.resolve(__dirname, "contracts", "Inbox.sol");
    const source = fs.readFileSync(inboxPath, "utf8");
    module.exports = solc.compile(source,1).contracts[":Inbox"];


    After running //npm run test // I get this error:

    cmd-mocha error.jpg

    and here is my debug.log file:

    debug.lof file.jpg

    I tried clearing my npm cache, unistalling async with a newer version but with no luck, the error still presists.

    I˙m doing a solidity ethereum course od Udemy but I don`t get any answers from their side so I would really appreciate some help here...

  • This is the community forum for NodeBB, the node.js based forum software. It's not meant to be for general node.js questions.

    You're free to ask here but you're unlikely to get an answer.

Suggested Topics

  • Error when importing library

    Unsolved Plugin Development
    0 Votes
    7 Posts
  • 0 Votes
    7 Posts
  • 0 Votes
    1 Posts
  • 0 Votes
    7 Posts
  • two plugin error

    Plugin Development
    0 Votes
    7 Posts