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

Commit af32ecf

Browse files
hacdiasdaviddias
authored andcommitted
fix: stats not implemented on jsipfs (#209)
* fix: stats not implemented on jsipfs * fix: return done() * fix: add return to promises
1 parent 290ab91 commit af32ecf

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/stats.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ chai.use(dirtyChai)
1111
module.exports = (common) => {
1212
describe('.stats', () => {
1313
let ipfs
14+
let withGo
1415

1516
before(function (done) {
1617
// CI takes longer to instantiate the daemon, so we need to increase the
@@ -22,7 +23,11 @@ module.exports = (common) => {
2223
factory.spawnNode((err, node) => {
2324
expect(err).to.not.exist()
2425
ipfs = node
25-
done()
26+
node.id((err, id) => {
27+
expect(err).to.not.exist()
28+
withGo = id.agentVersion.startsWith('go-ipfs')
29+
done()
30+
})
2631
})
2732
})
2833
})
@@ -32,6 +37,11 @@ module.exports = (common) => {
3237
})
3338

3439
it('.bitswap', (done) => {
40+
if (!withGo) {
41+
console.log('Not supported in js-ipfs yet')
42+
return done()
43+
}
44+
3545
ipfs.stats.bitswap((err, res) => {
3646
expect(err).to.not.exist()
3747
expect(res).to.exist()
@@ -49,6 +59,11 @@ module.exports = (common) => {
4959
})
5060

5161
it('.bitswap Promise', () => {
62+
if (!withGo) {
63+
console.log('Not supported in js-ipfs yet')
64+
return
65+
}
66+
5267
return ipfs.stats.bitswap().then((res) => {
5368
expect(res).to.exist()
5469
expect(res).to.have.a.property('provideBufLen')
@@ -64,6 +79,11 @@ module.exports = (common) => {
6479
})
6580

6681
it('.bw', (done) => {
82+
if (!withGo) {
83+
console.log('Not supported in js-ipfs yet')
84+
return done()
85+
}
86+
6787
ipfs.stats.bw((err, res) => {
6888
expect(err).to.not.exist()
6989
expect(res).to.exist()
@@ -76,6 +96,11 @@ module.exports = (common) => {
7696
})
7797

7898
it('.bw Promise', () => {
99+
if (!withGo) {
100+
console.log('Not supported in js-ipfs yet')
101+
return
102+
}
103+
79104
return ipfs.stats.bw().then((res) => {
80105
expect(res).to.exist()
81106
expect(res).to.have.a.property('totalIn')
@@ -86,6 +111,11 @@ module.exports = (common) => {
86111
})
87112

88113
it('.repo', (done) => {
114+
if (!withGo) {
115+
console.log('Not supported in js-ipfs yet')
116+
return done()
117+
}
118+
89119
ipfs.stats.repo((err, res) => {
90120
expect(err).to.not.exist()
91121
expect(res).to.exist()
@@ -99,6 +129,11 @@ module.exports = (common) => {
99129
})
100130

101131
it('.repo Promise', () => {
132+
if (!withGo) {
133+
console.log('Not supported in js-ipfs yet')
134+
return
135+
}
136+
102137
return ipfs.stats.repo().then((res) => {
103138
expect(res).to.exist()
104139
expect(res).to.have.a.property('numObjects')

0 commit comments

Comments
 (0)