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:
compile.js
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
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:
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);
});
});
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
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