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

Commit

Permalink
fix: stats not implemented on jsipfs (#209)
Browse files Browse the repository at this point in the history
* fix: stats not implemented on jsipfs

* fix: return done()

* fix: add return to promises
  • Loading branch information
hacdias authored and daviddias committed Jan 25, 2018
1 parent 290ab91 commit af32ecf
Showing 1 changed file with 36 additions and 1 deletion.
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

0 comments on commit af32ecf

Please sign in to comment.