forked from ipfs-inactive/js-ipfs-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitswap.spec.js
67 lines (59 loc) · 1.74 KB
/
bitswap.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* eslint-env mocha */
/* globals apiClients */
'use strict'
const expect = require('chai').expect
describe('.bitswap', () => {
it('.wantlist', (done) => {
apiClients.a.bitswap.wantlist((err, res) => {
expect(err).to.not.exist
expect(res).to.have.to.be.eql({
Keys: null
})
done()
})
})
it('.stat', (done) => {
apiClients.a.bitswap.stat((err, res) => {
expect(err).to.not.exist
expect(res).to.have.property('BlocksReceived')
expect(res).to.have.property('DupBlksReceived')
expect(res).to.have.property('DupDataReceived')
expect(res).to.have.property('Peers')
expect(res).to.have.property('ProvideBufLen')
expect(res).to.have.property('Wantlist')
done()
})
})
it('.unwant', (done) => {
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
apiClients.a.bitswap.unwant(key, (err) => {
expect(err).to.not.exist
done()
})
})
describe('promise', () => {
it('.wantlist', () => {
return apiClients.a.bitswap.wantlist()
.then((res) => {
expect(res).to.have.to.be.eql({
Keys: null
})
})
})
it('.stat', () => {
return apiClients.a.bitswap.stat()
.then((res) => {
expect(res).to.have.property('BlocksReceived')
expect(res).to.have.property('DupBlksReceived')
expect(res).to.have.property('DupDataReceived')
expect(res).to.have.property('Peers')
expect(res).to.have.property('ProvideBufLen')
expect(res).to.have.property('Wantlist')
})
})
it('.unwant', () => {
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
return apiClients.a.bitswap.unwant(key)
})
})
})