×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Async library error in terminal while running Ethereum Smart Contracts test with mocha?

Async library error in terminal while running Ethereum Smart Contracts test with mocha?

Async library error in terminal while running Ethereum Smart Contracts test with mocha?

(OP)
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 help forums and was informed that the nature of the error is with async.

async version is 2.6.2
async-await version is 0.1.40

Inbox.test.js:

CODE --> javascript

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", () => {

		console.log(inbox);
	});
}); 

CODE --> json

package.json:

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

compile.js

CODE --> javascript

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 i run: npm run test // in my cmd I get this output



I tried clearing my npm cache, unistalling async / async await 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…

Tnx


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close