'use strict';

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

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

const isBigInt = n => {
  return typeof n === 'bigint';
};
function expectIsBitswap(err, stats) {
  chai_js.expect(err).to.not.exist();
  chai_js.expect(stats).to.exist();
  chai_js.expect(stats).to.have.a.property('provideBufLen');
  chai_js.expect(stats).to.have.a.property('wantlist');
  chai_js.expect(stats).to.have.a.property('peers');
  chai_js.expect(stats).to.have.a.property('blocksReceived');
  chai_js.expect(stats).to.have.a.property('dataReceived');
  chai_js.expect(stats).to.have.a.property('blocksSent');
  chai_js.expect(stats).to.have.a.property('dataSent');
  chai_js.expect(stats).to.have.a.property('dupBlksReceived');
  chai_js.expect(stats).to.have.a.property('dupDataReceived');
  chai_js.expect(stats.provideBufLen).to.a('number');
  chai_js.expect(stats.wantlist).to.be.an('array');
  chai_js.expect(stats.peers).to.be.an('array');
  chai_js.expect(isBigInt(stats.blocksReceived)).to.eql(true);
  chai_js.expect(isBigInt(stats.dataReceived)).to.eql(true);
  chai_js.expect(isBigInt(stats.blocksSent)).to.eql(true);
  chai_js.expect(isBigInt(stats.dataSent)).to.eql(true);
  chai_js.expect(isBigInt(stats.dupBlksReceived)).to.eql(true);
  chai_js.expect(isBigInt(stats.dupDataReceived)).to.eql(true);
}
function expectIsBandwidth(err, stats) {
  chai_js.expect(err).to.not.exist();
  chai_js.expect(stats).to.exist();
  chai_js.expect(stats).to.have.a.property('totalIn');
  chai_js.expect(stats).to.have.a.property('totalOut');
  chai_js.expect(stats).to.have.a.property('rateIn');
  chai_js.expect(stats).to.have.a.property('rateOut');
  chai_js.expect(isBigInt(stats.totalIn)).to.eql(true);
  chai_js.expect(isBigInt(stats.totalOut)).to.eql(true);
  chai_js.expect(stats.rateIn).to.be.a('number');
  chai_js.expect(stats.rateOut).to.be.a('number');
}
function expectIsRepo(err, res) {
  chai_js.expect(err).to.not.exist();
  chai_js.expect(res).to.exist();
  chai_js.expect(res).to.have.a.property('numObjects');
  chai_js.expect(res).to.have.a.property('repoSize');
  chai_js.expect(res).to.have.a.property('repoPath');
  chai_js.expect(res).to.have.a.property('version');
  chai_js.expect(res).to.have.a.property('storageMax');
  chai_js.expect(isBigInt(res.numObjects)).to.eql(true);
  chai_js.expect(isBigInt(res.repoSize)).to.eql(true);
  chai_js.expect(isBigInt(res.storageMax)).to.eql(true);
  chai_js.expect(res.repoPath).to.be.a('string');
  chai_js.expect(res.version).to.be.a('string');
}

exports.expectIsBandwidth = expectIsBandwidth;
exports.expectIsBitswap = expectIsBitswap;
exports.expectIsRepo = expectIsRepo;
