diff --git a/test/core/bitswap.spec.js b/test/core/bitswap.spec.js index 029ee03072..ec46f6f3fb 100644 --- a/test/core/bitswap.spec.js +++ b/test/core/bitswap.spec.js @@ -259,8 +259,11 @@ describe('bitswap', function () { expect(() => node.bitswap.wantlist()).to.throw(/online/) }) - it('.stat throws while offline', () => { - expect(() => node.bitswap.stat()).to.throw(/online/) + it('.stat gives error while offline', () => { + node.bitswap.stat((err, stats) => { + expect(err).to.exist() + expect(stats).to.not.exist() + }) }) it('throws if offline', () => { @@ -279,22 +282,24 @@ describe('bitswap', function () { expect(node.bitswap.wantlist()).to.eql([]) }) - it('returns the stats', () => { - let stats = node.bitswap.stat() - - expect(stats).to.have.keys([ - 'blocksReceived', - 'blocksSent', - 'dataReceived', - 'dataSent', - 'wantListLength', - 'wantlist', - 'peerCount', - 'peers', - 'providesBufferLength', - 'dupDataReceived', - 'dupBlksReceived' - ]) + it('returns the stats', (done) => { + node.bitswap.stat((err, stats) => { + expect(err).to.not.exist() + expect(stats).to.have.keys([ + 'blocksReceived', + 'blocksSent', + 'dataReceived', + 'dataSent', + 'wantListLength', + 'wantlist', + 'peerCount', + 'peers', + 'providesBufferLength', + 'dupDataReceived', + 'dupBlksReceived' + ]) + done() + }) }) }) }) diff --git a/test/http-api/spec/bitswap.js b/test/http-api/spec/bitswap.js index f290dc9661..16e2c6ceef 100644 --- a/test/http-api/spec/bitswap.js +++ b/test/http-api/spec/bitswap.js @@ -28,14 +28,15 @@ module.exports = (http) => { url: '/api/v0/bitswap/stat' }, (res) => { expect(res.statusCode).to.equal(200) - - expect(res.result).to.have.keys([ - 'BlocksReceived', - 'Wantlist', - 'Peers', - 'DupBlksReceived', - 'DupDataReceived' - ]) + expect(res.result).to.have.property('ProvideBufLen') + expect(res.result).to.have.property('BlocksReceived') + expect(res.result).to.have.property('Wantlist') + expect(res.result).to.have.property('Peers') + expect(res.result).to.have.property('DupBlksReceived') + expect(res.result).to.have.property('DupDataReceived') + expect(res.result).to.have.property('DataReceived') + expect(res.result).to.have.property('BlocksSent') + expect(res.result).to.have.property('DataSent') done() }) })