问题描述
当我使用 Mocha 测试我的 js 文件时总是收到警告。
(节点:279853)MaxListenersExceededWarning:检测到可能的 EventEmitter 内存泄漏。 11 个数据监听器添加到 [l]。使用emitter.setMaxListeners()增加限制
const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const CompiledFactory = require('../ethereum/build/factory_campaign.json');
const CompiledCampaign = require('../ethereum/build/Campaign.json');
let accounts;
let factory;
let campaignAddress;
let campaign;
beforeEach(async ()=>{
accounts = await web3.eth.getAccounts();
factory = await new web3.eth.Contract(JSON.parse(CompiledFactory.interface))
.deploy({data: CompiledFactory.bytecode})
.send({from: accounts[0],gas:'1000000'});
await factory.methods.create_campain('9999999999').send({
from: accounts[0],gas:1000000
});
const address = await factory.methods.getContract().call();
campaignAddress = address[0];
campaign = await new web3.eth.Contract(JSON.parse(CompiledCampaign.interface),campaignAddress);
});
describe('Factory and Campaign...',() =>{
it('deploy a contract for Campaign and Factory',()=>{
assert.ok(factory.options.address);
assert.ok(campaign.options.address);
});
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)