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

Commit b9638ba

Browse files
committed
fix: avoid too many changes
1 parent 90b01dc commit b9638ba

15 files changed

+163
-129
lines changed

test/bitswap.spec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ const df = DaemonFactory.create()
1111

1212
describe('.bitswap', function () {
1313
this.timeout(20 * 1000) // slow CI
14+
let ipfs
1415
let ipfsd = null
1516

1617
before((done) => {
1718
this.timeout(20 * 1000) // slow CI
1819
df.spawn((err, node) => {
1920
expect(err).to.not.exist()
2021
ipfsd = node
22+
ipfs = node.api
2123
done()
2224
})
2325
})
@@ -26,7 +28,7 @@ describe('.bitswap', function () {
2628

2729
describe('Callback API', () => {
2830
it('.wantlist', (done) => {
29-
ipfsd.api.bitswap.wantlist((err, res) => {
31+
ipfs.bitswap.wantlist((err, res) => {
3032
expect(err).to.not.exist()
3133
expect(res).to.have.to.be.eql({
3234
Keys: null
@@ -36,7 +38,7 @@ describe('.bitswap', function () {
3638
})
3739

3840
it('.stat', (done) => {
39-
ipfsd.api.bitswap.stat((err, res) => {
41+
ipfs.bitswap.stat((err, res) => {
4042
expect(err).to.not.exist()
4143
expect(res).to.have.property('BlocksReceived')
4244
expect(res).to.have.property('DupBlksReceived')
@@ -51,7 +53,7 @@ describe('.bitswap', function () {
5153

5254
it('.unwant', (done) => {
5355
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
54-
ipfsd.api.bitswap.unwant(key, (err) => {
56+
ipfs.bitswap.unwant(key, (err) => {
5557
expect(err).to.not.exist()
5658
done()
5759
})
@@ -60,7 +62,7 @@ describe('.bitswap', function () {
6062

6163
describe('Promise API', () => {
6264
it('.wantlist', () => {
63-
return ipfsd.api.bitswap.wantlist()
65+
return ipfs.bitswap.wantlist()
6466
.then((res) => {
6567
expect(res).to.have.to.be.eql({
6668
Keys: null
@@ -69,7 +71,7 @@ describe('.bitswap', function () {
6971
})
7072

7173
it('.stat', () => {
72-
return ipfsd.api.bitswap.stat()
74+
return ipfs.bitswap.stat()
7375
.then((res) => {
7476
expect(res).to.have.property('BlocksReceived')
7577
expect(res).to.have.property('DupBlksReceived')
@@ -82,7 +84,7 @@ describe('.bitswap', function () {
8284

8385
it('.unwant', () => {
8486
const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
85-
return ipfsd.api.bitswap.unwant(key)
87+
return ipfs.bitswap.unwant(key)
8688
})
8789
})
8890
})

test/bootstrap.spec.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ describe('.bootstrap', function () {
1717
this.timeout(100 * 1000)
1818

1919
let ipfsd
20+
let ipfs
2021

2122
before((done) => {
2223
df.spawn((err, node) => {
2324
expect(err).to.not.exist()
2425
ipfsd = node
26+
ipfs = node.api
2527
done()
2628
})
2729
})
@@ -35,14 +37,14 @@ describe('.bootstrap', function () {
3537

3638
describe('.add', () => {
3739
it('returns an error when called with an invalid arg', (done) => {
38-
ipfsd.api.bootstrap.add(invalidArg, (err) => {
40+
ipfs.bootstrap.add(invalidArg, (err) => {
3941
expect(err).to.be.an.instanceof(Error)
4042
done()
4143
})
4244
})
4345

4446
it('returns a list of containing the bootstrap peer when called with a valid arg (ip4)', (done) => {
45-
ipfsd.api.bootstrap.add(validIp4, (err, res) => {
47+
ipfs.bootstrap.add(validIp4, (err, res) => {
4648
expect(err).to.not.exist()
4749
expect(res).to.be.eql({ Peers: [validIp4] })
4850
peers = res.Peers
@@ -53,7 +55,7 @@ describe('.bootstrap', function () {
5355
})
5456

5557
it('returns a list of bootstrap peers when called with the default option', (done) => {
56-
ipfsd.api.bootstrap.add({ default: true }, (err, res) => {
58+
ipfs.bootstrap.add({ default: true }, (err, res) => {
5759
expect(err).to.not.exist()
5860
peers = res.Peers
5961
expect(peers).to.exist()
@@ -65,7 +67,7 @@ describe('.bootstrap', function () {
6567

6668
describe('.list', () => {
6769
it('returns a list of peers', (done) => {
68-
ipfsd.api.bootstrap.list((err, res) => {
70+
ipfs.bootstrap.list((err, res) => {
6971
expect(err).to.not.exist()
7072
peers = res.Peers
7173
expect(peers).to.exist()
@@ -76,14 +78,14 @@ describe('.bootstrap', function () {
7678

7779
describe('.rm', () => {
7880
it('returns an error when called with an invalid arg', (done) => {
79-
ipfsd.api.bootstrap.rm(invalidArg, (err) => {
81+
ipfs.bootstrap.rm(invalidArg, (err) => {
8082
expect(err).to.be.an.instanceof(Error)
8183
done()
8284
})
8385
})
8486

8587
it('returns empty list because no peers removed when called without an arg or options', (done) => {
86-
ipfsd.api.bootstrap.rm(null, (err, res) => {
88+
ipfs.bootstrap.rm(null, (err, res) => {
8789
expect(err).to.not.exist()
8890
peers = res.Peers
8991
expect(peers).to.exist()
@@ -93,7 +95,7 @@ describe('.bootstrap', function () {
9395
})
9496

9597
it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => {
96-
ipfsd.api.bootstrap.rm(null, (err, res) => {
98+
ipfs.bootstrap.rm(null, (err, res) => {
9799
expect(err).to.not.exist()
98100
peers = res.Peers
99101
expect(peers).to.exist()
@@ -103,7 +105,7 @@ describe('.bootstrap', function () {
103105
})
104106

105107
it('returns list of all peers removed when all option is passed', (done) => {
106-
ipfsd.api.bootstrap.rm(null, { all: true }, (err, res) => {
108+
ipfs.bootstrap.rm(null, { all: true }, (err, res) => {
107109
expect(err).to.not.exist()
108110
peers = res.Peers
109111
expect(peers).to.exist()
@@ -118,21 +120,21 @@ describe('.bootstrap', function () {
118120

119121
describe('.add', () => {
120122
it('returns an error when called without args or options', () => {
121-
return ipfsd.api.bootstrap.add(null)
123+
return ipfs.bootstrap.add(null)
122124
.catch((err) => {
123125
expect(err).to.be.an.instanceof(Error)
124126
})
125127
})
126128

127129
it('returns an error when called with an invalid arg', () => {
128-
return ipfsd.api.bootstrap.add(invalidArg)
130+
return ipfs.bootstrap.add(invalidArg)
129131
.catch((err) => {
130132
expect(err).to.be.an.instanceof(Error)
131133
})
132134
})
133135

134136
it('returns a list of peers when called with a valid arg (ip4)', () => {
135-
return ipfsd.api.bootstrap.add(validIp4)
137+
return ipfs.bootstrap.add(validIp4)
136138
.then((res) => {
137139
expect(res).to.be.eql({ Peers: [validIp4] })
138140
peers = res.Peers
@@ -142,7 +144,7 @@ describe('.bootstrap', function () {
142144
})
143145

144146
it('returns a list of default peers when called with the default option', () => {
145-
return ipfsd.api.bootstrap.add(null, { default: true })
147+
return ipfs.bootstrap.add(null, { default: true })
146148
.then((res) => {
147149
peers = res.Peers
148150
expect(peers).to.exist()
@@ -153,7 +155,7 @@ describe('.bootstrap', function () {
153155

154156
describe('.list', () => {
155157
it('returns a list of peers', () => {
156-
return ipfsd.api.bootstrap.list()
158+
return ipfs.bootstrap.list()
157159
.then((res) => {
158160
peers = res.Peers
159161
expect(peers).to.exist()
@@ -163,14 +165,14 @@ describe('.bootstrap', function () {
163165

164166
describe('.rm', () => {
165167
it('returns an error when called with an invalid arg', () => {
166-
return ipfsd.api.bootstrap.rm(invalidArg)
168+
return ipfs.bootstrap.rm(invalidArg)
167169
.catch((err) => {
168170
expect(err).to.be.an.instanceof(Error)
169171
})
170172
})
171173

172174
it('returns empty list when called without an arg or options', () => {
173-
return ipfsd.api.bootstrap.rm(null)
175+
return ipfs.bootstrap.rm(null)
174176
.then((res) => {
175177
peers = res.Peers
176178
expect(peers).to.exist()
@@ -179,7 +181,7 @@ describe('.bootstrap', function () {
179181
})
180182

181183
it('returns list containing the peer removed when called with a valid arg (ip4)', () => {
182-
return ipfsd.api.bootstrap.rm(null)
184+
return ipfs.bootstrap.rm(null)
183185
.then((res) => {
184186
peers = res.Peers
185187
expect(peers).to.exist()
@@ -188,7 +190,7 @@ describe('.bootstrap', function () {
188190
})
189191

190192
it('returns list of all peers removed when all option is passed', () => {
191-
return ipfsd.api.bootstrap.rm(null, { all: true })
193+
return ipfs.bootstrap.rm(null, { all: true })
192194
.then((res) => {
193195
peers = res.Peers
194196
expect(peers).to.exist()

test/commands.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ describe('.commands', function () {
1313
this.timeout(20 * 1000)
1414

1515
let ipfsd
16+
let ipfs
1617

1718
before((done) => {
1819
df.spawn((err, node) => {
1920
expect(err).to.not.exist()
2021
ipfsd = node
22+
ipfs = node.api
2123
done()
2224
})
2325
})
2426

2527
after((done) => ipfsd.stop(done))
2628

2729
it('lists commands', (done) => {
28-
ipfsd.api.commands((err, res) => {
30+
ipfs.commands((err, res) => {
2931
expect(err).to.not.exist()
3032
expect(res).to.exist()
3133
done()
@@ -34,7 +36,7 @@ describe('.commands', function () {
3436

3537
describe('promise', () => {
3638
it('lists commands', () => {
37-
return ipfsd.api.commands()
39+
return ipfs.commands()
3840
.then((res) => {
3941
expect(res).to.exist()
4042
})

test/diag.spec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ describe('.diag', function () {
1919
}
2020

2121
let ipfsd
22+
let ipfs
2223

2324
before((done) => {
2425
df.spawn((err, node) => {
2526
expect(err).to.not.exist()
2627
ipfsd = node
28+
ipfs = node.api
2729
done()
2830
})
2931
})
@@ -33,15 +35,15 @@ describe('.diag', function () {
3335
describe('Callback API', () => {
3436
// Disabled in go-ipfs 0.4.10
3537
it.skip('.diag.net', (done) => {
36-
ipfsd.api.diag.net((err, res) => {
38+
ipfs.diag.net((err, res) => {
3739
expect(err).to.not.exist()
3840
expect(res).to.exist()
3941
done()
4042
})
4143
})
4244

4345
it('.diag.sys', (done) => {
44-
ipfsd.api.diag.sys((err, res) => {
46+
ipfs.diag.sys((err, res) => {
4547
expect(err).to.not.exist()
4648
expect(res).to.exist()
4749
expect(res).to.have.a.property('memory')
@@ -51,7 +53,7 @@ describe('.diag', function () {
5153
})
5254

5355
it('.diag.cmds', (done) => {
54-
ipfsd.api.diag.cmds((err, res) => {
56+
ipfs.diag.cmds((err, res) => {
5557
expect(err).to.not.exist()
5658
expect(res).to.exist()
5759
done()
@@ -62,12 +64,12 @@ describe('.diag', function () {
6264
describe('Promise API', () => {
6365
// Disabled in go-ipfs 0.4.10
6466
it.skip('.diag.net', () => {
65-
return ipfsd.api.diag.net()
67+
return ipfs.diag.net()
6668
.then((res) => expect(res).to.exist())
6769
})
6870

6971
it('.diag.sys', () => {
70-
return ipfsd.api.diag.sys()
72+
return ipfs.diag.sys()
7173
.then((res) => {
7274
expect(res).to.exist()
7375
expect(res).to.have.a.property('memory')
@@ -76,7 +78,7 @@ describe('.diag', function () {
7678
})
7779

7880
it('.diag.cmds', () => {
79-
return ipfsd.api.diag.cmds()
81+
return ipfs.diag.cmds()
8082
.then((res) => expect(res).to.exist())
8183
})
8284
})

0 commit comments

Comments
 (0)