Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit c371c77

Browse files
author
Pedro Santos
committed
test: add human readable test to stats bitswap
1 parent 7cf6782 commit c371c77

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/stats/bitswap.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,34 @@ module.exports = (createCommon, options) => {
4141
expectIsBitswap(null, res)
4242
})
4343
})
44+
45+
it('should get human readable bitswap stats', async () => {
46+
const stats = await ipfs.stats.bitswap({ human: true })
47+
48+
expect(stats).to.exist()
49+
expect(stats).to.have.a.property('provideBufLen')
50+
.and.to.be.a('number')
51+
expect(stats).to.have.a.property('blocksReceived')
52+
.and.to.be.a('number')
53+
expect(stats).to.have.a.property('wantlist')
54+
.and.to.be.a('string')
55+
.and.to.match(/\[\d+\skeys\]$/gm)
56+
expect(stats).to.have.a.property('peers')
57+
.and.to.be.a('string')
58+
.and.to.match(/\[\d+\]$/gm)
59+
expect(stats).to.have.a.property('dupBlksReceived')
60+
.and.to.be.a('number')
61+
expect(stats).to.have.a.property('dupDataReceived')
62+
.and.to.be.a('string')
63+
.and.to.match(/[\d.]+\s[PTGMK]?B$/gm)
64+
expect(stats).to.have.a.property('dataReceived')
65+
.and.to.be.a('string')
66+
.and.to.match(/[\d.]+\s[PTGMK]?B$/gm)
67+
expect(stats).to.have.a.property('blocksSent')
68+
.and.to.be.a('number')
69+
expect(stats).to.have.a.property('dataSent')
70+
.and.to.be.a('string')
71+
.and.to.match(/[\d.]+\s[PTGMK]?B$/gm)
72+
})
4473
})
4574
}

0 commit comments

Comments
 (0)