From 1da421c0c4bdf4ab1193fb68579689a335cbcd7a Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 25 Jan 2018 18:47:08 +0000 Subject: [PATCH 1/3] fix: stats not implemented on jsipfs --- src/stats.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/stats.js b/src/stats.js index 8393e5e7..f7a25ce9 100644 --- a/src/stats.js +++ b/src/stats.js @@ -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 @@ -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() + }) }) }) }) @@ -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() @@ -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') @@ -64,6 +79,11 @@ module.exports = (common) => { }) it('.bw', (done) => { + if (!withGo) { + console.log('Not supported in js-ipfs yet') + return + } + ipfs.stats.bw((err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -76,7 +96,12 @@ module.exports = (common) => { }) it('.bw Promise', () => { - return ipfs.stats.bw().then((res) => { + if (!withGo) { + console.log('Not supported in js-ipfs yet') + return + } + + ipfs.stats.bw().then((res) => { expect(res).to.exist() expect(res).to.have.a.property('totalIn') expect(res).to.have.a.property('totalOut') @@ -86,6 +111,11 @@ module.exports = (common) => { }) it('.repo', (done) => { + if (!withGo) { + console.log('Not supported in js-ipfs yet') + return + } + ipfs.stats.repo((err, res) => { expect(err).to.not.exist() expect(res).to.exist() @@ -99,7 +129,12 @@ module.exports = (common) => { }) it('.repo Promise', () => { - return ipfs.stats.repo().then((res) => { + if (!withGo) { + console.log('Not supported in js-ipfs yet') + return + } + + ipfs.stats.repo().then((res) => { expect(res).to.exist() expect(res).to.have.a.property('numObjects') expect(res).to.have.a.property('repoSize') From f5d4277c22a01ddf6558a70efce38a7273ef172b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 25 Jan 2018 18:48:43 +0000 Subject: [PATCH 2/3] fix: return done() --- src/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stats.js b/src/stats.js index f7a25ce9..f357a09f 100644 --- a/src/stats.js +++ b/src/stats.js @@ -81,7 +81,7 @@ module.exports = (common) => { it('.bw', (done) => { if (!withGo) { console.log('Not supported in js-ipfs yet') - return + return done() } ipfs.stats.bw((err, res) => { @@ -113,7 +113,7 @@ module.exports = (common) => { it('.repo', (done) => { if (!withGo) { console.log('Not supported in js-ipfs yet') - return + return done() } ipfs.stats.repo((err, res) => { From 3f5789589af8faefbcfc29b7ba5a30b407136691 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 25 Jan 2018 20:17:11 +0000 Subject: [PATCH 3/3] fix: add return to promises --- src/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stats.js b/src/stats.js index f357a09f..58703c2e 100644 --- a/src/stats.js +++ b/src/stats.js @@ -101,7 +101,7 @@ module.exports = (common) => { return } - ipfs.stats.bw().then((res) => { + return ipfs.stats.bw().then((res) => { expect(res).to.exist() expect(res).to.have.a.property('totalIn') expect(res).to.have.a.property('totalOut') @@ -134,7 +134,7 @@ module.exports = (common) => { return } - ipfs.stats.repo().then((res) => { + return ipfs.stats.repo().then((res) => { expect(res).to.exist() expect(res).to.have.a.property('numObjects') expect(res).to.have.a.property('repoSize')