我正在尝试使用mocha和ganache部署简单的合同,但出现此错误: 合同 1)“部署合同”的“在每个之前”钩子
0 passing (30s)
1 failing
1) "before each" hook for "Deploys a Contract":
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure
"done()" is called; if returning a Promise, ensure it resolves.
合同代码:
pragma solidity ^0.4.17;
contract Acontract {
string public message; // new variable
function Acontract(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {
message = newMessage;
}
}
测试文件代码:
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 result;
beforeEach( async () => {
accounts = await web3.eth.getAccounts();
result = await new web3.eth.Contract(JSON.parse(interface))
.deploy ({ data: bytecode, arguments: ['WOW'] })
.send({ from: accounts[0], gas: '1000000'});
});
describe('Acontract', ()=> {
it('Deploys a Contract', async ()=>{
console.log(result)
});
});
如何解决此错误,代码很简单,我测试了获取帐户的权限,还可以,也可以部署,但是在发送代码时不起作用!有什么建议吗?