微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

节点:279853MaxListenersExceededWarning:检测到可能的 EventEmitter 内存泄漏

如何解决节点:279853MaxListenersExceededWarning:检测到可能的 EventEmitter 内存泄漏

当我使用 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 举报,一经查实,本站将立刻删除。