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

fix: stats not implemented on jsipfs #209

Merged
merged 3 commits into from
Jan 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ chai.use(dirtyChai)
module.exports = (common) => {
describe('.stats', () => {
let ipfs
let withGo

before(function (done) {
// CI takes longer to instantiate the daemon, so we need to increase the
Expand All @@ -22,7 +23,11 @@ module.exports = (common) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node
done()
node.id((err, id) => {
expect(err).to.not.exist()
withGo = id.agentVersion.startsWith('go-ipfs')
done()
})
})
})
})
Expand All @@ -32,6 +37,11 @@ module.exports = (common) => {
})

it('.bitswap', (done) => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return done()
}

ipfs.stats.bitswap((err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
Expand All @@ -49,6 +59,11 @@ module.exports = (common) => {
})

it('.bitswap Promise', () => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return
}

return ipfs.stats.bitswap().then((res) => {
expect(res).to.exist()
expect(res).to.have.a.property('provideBufLen')
Expand All @@ -64,6 +79,11 @@ module.exports = (common) => {
})

it('.bw', (done) => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return done()
}

ipfs.stats.bw((err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
Expand All @@ -76,6 +96,11 @@ module.exports = (common) => {
})

it('.bw Promise', () => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return
}

return ipfs.stats.bw().then((res) => {
expect(res).to.exist()
expect(res).to.have.a.property('totalIn')
Expand All @@ -86,6 +111,11 @@ module.exports = (common) => {
})

it('.repo', (done) => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return done()
}

ipfs.stats.repo((err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
Expand All @@ -99,6 +129,11 @@ module.exports = (common) => {
})

it('.repo Promise', () => {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
return
}

return ipfs.stats.repo().then((res) => {
expect(res).to.exist()
expect(res).to.have.a.property('numObjects')
Expand Down