'use strict';

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

var chai_js = require('aegir/utils/chai.js');
var mocha = require('../utils/mocha.js');
var utils = require('../stats/utils.js');

function testStat(factory, options) {
  const describe = mocha.getDescribe(options);
  const it = mocha.getIt(options);
  describe('.bitswap.stat', function () {
    this.timeout(60 * 1000);
    let ipfs;
    before(async () => {
      ipfs = (await factory.spawn()).api;
    });
    after(() => factory.clean());
    it('should get bitswap stats', async () => {
      const res = await ipfs.bitswap.stat();
      utils.expectIsBitswap(null, res);
    });
    it('should not get bitswap stats when offline', async () => {
      const node = await factory.spawn();
      await node.stop();
      return chai_js.expect(node.api.bitswap.stat()).to.eventually.be.rejected();
    });
  });
}

exports.testStat = testStat;
