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

Commit 01d7c16

Browse files
daviddiasdryajov
authored andcommitted
clean bitswap tests
1 parent 74ecf1c commit 01d7c16

File tree

2 files changed

+56
-129
lines changed

2 files changed

+56
-129
lines changed

test/bitswap.spec.js

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,65 +26,35 @@ describe('.bitswap', function () {
2626

2727
after((done) => ipfsd.stop(done))
2828

29-
describe('Callback API', () => {
30-
it('.wantlist', (done) => {
31-
ipfs.bitswap.wantlist((err, res) => {
32-
expect(err).to.not.exist()
33-
expect(res).to.have.to.be.eql({
34-
Keys: null
35-
})
36-
done()
37-
})
38-
})
39-
40-
it('.stat', (done) => {
41-
ipfs.bitswap.stat((err, res) => {
42-
expect(err).to.not.exist()
43-
expect(res).to.have.property('BlocksReceived')
44-
expect(res).to.have.property('DupBlksReceived')
45-
expect(res).to.have.property('DupDataReceived')
46-
expect(res).to.have.property('Peers')
47-
expect(res).to.have.property('ProvideBufLen')
48-
expect(res).to.have.property('Wantlist')
49-
50-
done()
51-
})
52-
})
53-
54-
it('.unwant', (done) => {
55-
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
56-
ipfs.bitswap.unwant(key, (err) => {
57-
expect(err).to.not.exist()
58-
done()
29+
it('.wantlist', (done) => {
30+
ipfs.bitswap.wantlist((err, res) => {
31+
expect(err).to.not.exist()
32+
expect(res).to.have.to.eql({
33+
Keys: null
5934
})
35+
done()
6036
})
6137
})
6238

63-
describe('Promise API', () => {
64-
it('.wantlist', () => {
65-
return ipfs.bitswap.wantlist()
66-
.then((res) => {
67-
expect(res).to.have.to.be.eql({
68-
Keys: null
69-
})
70-
})
71-
})
39+
it('.stat', (done) => {
40+
ipfs.bitswap.stat((err, res) => {
41+
expect(err).to.not.exist()
42+
expect(res).to.have.property('BlocksReceived')
43+
expect(res).to.have.property('DupBlksReceived')
44+
expect(res).to.have.property('DupDataReceived')
45+
expect(res).to.have.property('Peers')
46+
expect(res).to.have.property('ProvideBufLen')
47+
expect(res).to.have.property('Wantlist')
7248

73-
it('.stat', () => {
74-
return ipfs.bitswap.stat()
75-
.then((res) => {
76-
expect(res).to.have.property('BlocksReceived')
77-
expect(res).to.have.property('DupBlksReceived')
78-
expect(res).to.have.property('DupDataReceived')
79-
expect(res).to.have.property('Peers')
80-
expect(res).to.have.property('ProvideBufLen')
81-
expect(res).to.have.property('Wantlist')
82-
})
49+
done()
8350
})
51+
})
8452

85-
it('.unwant', () => {
86-
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
87-
return ipfs.bitswap.unwant(key)
53+
it('.unwant', (done) => {
54+
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
55+
ipfs.bitswap.unwant(key, (err) => {
56+
expect(err).to.not.exist()
57+
done()
8858
})
8959
})
9060
})

test/stats.spec.js

Lines changed: 34 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -26,88 +26,45 @@ describe('stats', function () {
2626

2727
after((done) => ipfsd.stop(done))
2828

29-
describe('Callback API', () => {
30-
it('.stats.bitswap', (done) => {
31-
ipfs.stats.bitswap((err, res) => {
32-
expect(err).to.not.exist()
33-
expect(res).to.exist()
34-
expect(res).to.have.a.property('provideBufLen')
35-
expect(res).to.have.a.property('wantlist')
36-
expect(res).to.have.a.property('peers')
37-
expect(res).to.have.a.property('blocksReceived')
38-
expect(res).to.have.a.property('dataReceived')
39-
expect(res).to.have.a.property('blocksSent')
40-
expect(res).to.have.a.property('dataSent')
41-
expect(res).to.have.a.property('dupBlksReceived')
42-
expect(res).to.have.a.property('dupDataReceived')
43-
done()
44-
})
45-
})
46-
47-
it('.stats.bw', (done) => {
48-
ipfs.stats.bw((err, res) => {
49-
expect(err).to.not.exist()
50-
expect(res).to.exist()
51-
expect(res).to.have.a.property('totalIn')
52-
expect(res).to.have.a.property('totalOut')
53-
expect(res).to.have.a.property('rateIn')
54-
expect(res).to.have.a.property('rateOut')
55-
done()
56-
})
57-
})
58-
59-
it('.stats.repo', (done) => {
60-
ipfs.stats.repo((err, res) => {
61-
expect(err).to.not.exist()
62-
expect(res).to.exist()
63-
expect(res).to.have.a.property('numObjects')
64-
expect(res).to.have.a.property('repoSize')
65-
expect(res).to.have.a.property('repoPath')
66-
expect(res).to.have.a.property('version')
67-
expect(res).to.have.a.property('storageMax')
68-
done()
69-
})
29+
it('.stats.bitswap', (done) => {
30+
ipfs.stats.bitswap((err, res) => {
31+
expect(err).to.not.exist()
32+
expect(res).to.exist()
33+
expect(res).to.have.a.property('provideBufLen')
34+
expect(res).to.have.a.property('wantlist')
35+
expect(res).to.have.a.property('peers')
36+
expect(res).to.have.a.property('blocksReceived')
37+
expect(res).to.have.a.property('dataReceived')
38+
expect(res).to.have.a.property('blocksSent')
39+
expect(res).to.have.a.property('dataSent')
40+
expect(res).to.have.a.property('dupBlksReceived')
41+
expect(res).to.have.a.property('dupDataReceived')
42+
done()
7043
})
7144
})
7245

73-
describe('Promise API', () => {
74-
it('.stats.bw', () => {
75-
return ipfs.stats.bw()
76-
.then((res) => {
77-
expect(res).to.exist()
78-
expect(res).to.have.a.property('totalIn')
79-
expect(res).to.have.a.property('totalOut')
80-
expect(res).to.have.a.property('rateIn')
81-
expect(res).to.have.a.property('rateOut')
82-
})
83-
})
84-
85-
it('.stats.repo', () => {
86-
return ipfs.stats.repo()
87-
.then((res) => {
88-
expect(res).to.exist()
89-
expect(res).to.have.a.property('numObjects')
90-
expect(res).to.have.a.property('repoSize')
91-
expect(res).to.have.a.property('repoPath')
92-
expect(res).to.have.a.property('version')
93-
expect(res).to.have.a.property('storageMax')
94-
})
46+
it('.stats.bw', (done) => {
47+
ipfs.stats.bw((err, res) => {
48+
expect(err).to.not.exist()
49+
expect(res).to.exist()
50+
expect(res).to.have.a.property('totalIn')
51+
expect(res).to.have.a.property('totalOut')
52+
expect(res).to.have.a.property('rateIn')
53+
expect(res).to.have.a.property('rateOut')
54+
done()
9555
})
56+
})
9657

97-
it('.stats.bitswap', () => {
98-
return ipfs.stats.bitswap()
99-
.then((res) => {
100-
expect(res).to.exist()
101-
expect(res).to.have.a.property('provideBufLen')
102-
expect(res).to.have.a.property('wantlist')
103-
expect(res).to.have.a.property('peers')
104-
expect(res).to.have.a.property('blocksReceived')
105-
expect(res).to.have.a.property('dataReceived')
106-
expect(res).to.have.a.property('blocksSent')
107-
expect(res).to.have.a.property('dataSent')
108-
expect(res).to.have.a.property('dupBlksReceived')
109-
expect(res).to.have.a.property('dupDataReceived')
110-
})
58+
it('.stats.repo', (done) => {
59+
ipfs.stats.repo((err, res) => {
60+
expect(err).to.not.exist()
61+
expect(res).to.exist()
62+
expect(res).to.have.a.property('numObjects')
63+
expect(res).to.have.a.property('repoSize')
64+
expect(res).to.have.a.property('repoPath')
65+
expect(res).to.have.a.property('version')
66+
expect(res).to.have.a.property('storageMax')
67+
done()
11168
})
11269
})
11370
})

0 commit comments

Comments
 (0)