'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var chai_js = require('aegir/utils/chai.js');
var mocha = require('../utils/mocha.js');
var env_js = require('ipfs-utils/src/env.js');

function testLocalAddrs(factory, options) {
  const describe = mocha.getDescribe(options);
  const it = mocha.getIt(options);
  describe('.swarm.localAddrs', function () {
    this.timeout(80 * 1000);
    let ipfs;
    before(async () => {
      ipfs = (await factory.spawn()).api;
    });
    after(() => factory.clean());
    it('should list local addresses the node is listening on', async () => {
      const multiaddrs = await ipfs.swarm.localAddrs();
      chai_js.expect(multiaddrs).to.be.an.instanceOf(Array);
      if (env_js.isWebWorker && factory.opts.type === 'proc') {
        chai_js.expect(multiaddrs).to.have.lengthOf(0);
      } else {
        chai_js.expect(multiaddrs).to.not.be.empty();
      }
    });
  });
}

exports.testLocalAddrs = testLocalAddrs;
