Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit a0fd355

Browse files
committed
fix: stats tests
1 parent 905bdc0 commit a0fd355

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

test/core/bitswap.spec.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,11 @@ describe('bitswap', function () {
259259
expect(() => node.bitswap.wantlist()).to.throw(/online/)
260260
})
261261

262-
it('.stat throws while offline', () => {
263-
expect(() => node.bitswap.stat()).to.throw(/online/)
262+
it('.stat gives error while offline', () => {
263+
node.bitswap.stat((err, stats) => {
264+
expect(err).to.exist()
265+
expect(stats).to.not.exist()
266+
})
264267
})
265268

266269
it('throws if offline', () => {
@@ -279,22 +282,24 @@ describe('bitswap', function () {
279282
expect(node.bitswap.wantlist()).to.eql([])
280283
})
281284

282-
it('returns the stats', () => {
283-
let stats = node.bitswap.stat()
284-
285-
expect(stats).to.have.keys([
286-
'blocksReceived',
287-
'blocksSent',
288-
'dataReceived',
289-
'dataSent',
290-
'wantListLength',
291-
'wantlist',
292-
'peerCount',
293-
'peers',
294-
'providesBufferLength',
295-
'dupDataReceived',
296-
'dupBlksReceived'
297-
])
285+
it('returns the stats', (done) => {
286+
node.bitswap.stat((err, stats) => {
287+
expect(err).to.not.exist()
288+
expect(stats).to.have.keys([
289+
'blocksReceived',
290+
'blocksSent',
291+
'dataReceived',
292+
'dataSent',
293+
'wantListLength',
294+
'wantlist',
295+
'peerCount',
296+
'peers',
297+
'providesBufferLength',
298+
'dupDataReceived',
299+
'dupBlksReceived'
300+
])
301+
done()
302+
})
298303
})
299304
})
300305
})

test/http-api/spec/bitswap.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ module.exports = (http) => {
2828
url: '/api/v0/bitswap/stat'
2929
}, (res) => {
3030
expect(res.statusCode).to.equal(200)
31-
32-
expect(res.result).to.have.keys([
33-
'BlocksReceived',
34-
'Wantlist',
35-
'Peers',
36-
'DupBlksReceived',
37-
'DupDataReceived'
38-
])
31+
expect(res.result).to.have.property('ProvideBufLen')
32+
expect(res.result).to.have.property('BlocksReceived')
33+
expect(res.result).to.have.property('Wantlist')
34+
expect(res.result).to.have.property('Peers')
35+
expect(res.result).to.have.property('DupBlksReceived')
36+
expect(res.result).to.have.property('DupDataReceived')
37+
expect(res.result).to.have.property('DataReceived')
38+
expect(res.result).to.have.property('BlocksSent')
39+
expect(res.result).to.have.property('DataSent')
3940
done()
4041
})
4142
})

0 commit comments

Comments
 (0)