Skip to content

Commit 23421f3

Browse files
hugomrdiasAlan Shaw
authored and
Alan Shaw
committed
refactor: use new ipfsd-ctl setup (ipfs#1127)
* fix: use new ipfsd-ctl setup * chore: add correct branches * fix: support new ctl * fix: update to the latest ctl api * fix: use proper module * fix: override properly * chore: bump ipfsd-ctl, interface-core
1 parent 70c78d1 commit 23421f3

15 files changed

+106
-338
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
"cross-env": "^6.0.0",
8585
"detect-node": "^2.0.4",
8686
"go-ipfs-dep": "^0.4.22",
87-
"interface-ipfs-core": "^0.124.0",
88-
"ipfsd-ctl": "^0.47.1",
87+
"interface-ipfs-core": "~0.125.0",
88+
"ipfsd-ctl": "^1.0.0",
8989
"ndjson": "^1.5.0",
9090
"nock": "^11.4.0",
9191
"pull-stream": "^3.6.14",

test/commands.spec.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,18 @@
22
'use strict'
33

44
const { expect } = require('interface-ipfs-core/src/utils/mocha')
5-
const ipfsClient = require('../src')
65
const f = require('./utils/factory')
76

87
describe('.commands', function () {
98
this.timeout(60 * 1000)
109

11-
let ipfsd
1210
let ipfs
1311

1412
before(async () => {
15-
ipfsd = await f.spawn({
16-
initOptions: {
17-
bits: 1024,
18-
profile: 'test'
19-
}
20-
})
21-
ipfs = ipfsClient(ipfsd.apiAddr)
13+
ipfs = (await f.spawn()).api
2214
})
2315

24-
after(async () => {
25-
if (ipfsd) {
26-
await ipfsd.stop()
27-
}
28-
})
16+
after(() => f.clean())
2917

3018
it('lists commands', async () => {
3119
const res = await ipfs.commands()

test/constructor.spec.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,18 @@ describe('ipfs-http-client constructor tests', () => {
9393
})
9494

9595
describe('integration', () => {
96-
let apiAddr
9796
let ipfsd
9897

9998
before(async function () {
10099
this.timeout(60 * 1000) // slow CI
101100

102-
ipfsd = await f.spawn({ initOptions: { bits: 1024, profile: 'test' } })
103-
apiAddr = ipfsd.apiAddr.toString()
101+
ipfsd = await f.spawn()
104102
})
105103

106-
after(async () => {
107-
if (ipfsd) {
108-
await ipfsd.stop()
109-
}
110-
})
104+
after(() => f.clean())
111105

112106
it('can connect to an ipfs http api', async () => {
113-
await clientWorks(ipfsClient(apiAddr))
107+
await clientWorks(ipfsClient(ipfsd.apiAddr))
114108
})
115109
})
116110
})

test/dag.spec.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,17 @@
66
const { expect } = require('interface-ipfs-core/src/utils/mocha')
77
const { DAGNode } = require('ipld-dag-pb')
88
const CID = require('cids')
9-
const ipfsClient = require('../src')
109
const f = require('./utils/factory')
1110

12-
let ipfsd
1311
let ipfs
1412

1513
describe('.dag', function () {
1614
this.timeout(20 * 1000)
1715
before(async function () {
18-
ipfsd = await f.spawn({
19-
initOptions: {
20-
bits: 1024,
21-
profile: 'test'
22-
}
23-
})
24-
ipfs = ipfsClient(ipfsd.apiAddr)
16+
ipfs = (await f.spawn()).api
2517
})
2618

27-
after(async () => {
28-
if (ipfsd) {
29-
await ipfsd.stop()
30-
}
31-
})
19+
after(() => f.clean())
3220

3321
it('should be able to put and get a DAG node with format dag-pb', async () => {
3422
const data = Buffer.from('some data')

test/diag.spec.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
const { expect } = require('interface-ipfs-core/src/utils/mocha')
55
const platform = require('browser-process-platform')
6-
const ipfsClient = require('../src')
76
const f = require('./utils/factory')
87

98
describe('.diag', function () {
@@ -12,24 +11,13 @@ describe('.diag', function () {
1211
// go-ipfs does not support these on Windows
1312
if (platform === 'win32') { return }
1413

15-
let ipfsd
1614
let ipfs
1715

1816
before(async () => {
19-
ipfsd = await f.spawn({
20-
initOptions: {
21-
bits: 1024,
22-
profile: 'test'
23-
}
24-
})
25-
ipfs = ipfsClient(ipfsd.apiAddr)
17+
ipfs = (await f.spawn()).api
2618
})
2719

28-
after(async () => {
29-
if (ipfsd) {
30-
await ipfsd.stop()
31-
}
32-
})
20+
after(() => f.clean())
3321

3422
describe('api API', () => {
3523
// Disabled in go-ipfs 0.4.10

test/files-mfs.spec.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const values = require('pull-stream/sources/values')
1010
const pull = require('pull-stream/pull')
1111
const collect = require('pull-stream/sinks/collect')
1212

13-
const ipfsClient = require('../src')
1413
const f = require('./utils/factory')
1514
const expectTimeout = require('./utils/expect-timeout')
1615

@@ -31,26 +30,15 @@ const HASH_ALGS = [
3130
describe('.files (the MFS API part)', function () {
3231
this.timeout(20 * 1000)
3332

34-
let ipfsd
3533
let ipfs
3634

3735
const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
3836

3937
before(async () => {
40-
ipfsd = await f.spawn({
41-
initOptions: {
42-
bits: 1024,
43-
profile: 'test'
44-
}
45-
})
46-
ipfs = ipfsClient(ipfsd.apiAddr)
38+
ipfs = (await f.spawn()).api
4739
})
4840

49-
after(async () => {
50-
if (ipfsd) {
51-
await ipfsd.stop()
52-
}
53-
})
41+
after(() => f.clean())
5442

5543
it('.add file for testing', async () => {
5644
const res = await ipfs.add(testfile)

test/get.spec.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
const { expect } = require('interface-ipfs-core/src/utils/mocha')
77
const loadFixture = require('aegir/fixtures')
88

9-
const ipfsClient = require('../src')
109
const f = require('./utils/factory')
1110

1211
describe('.get (specific go-ipfs features)', function () {
@@ -21,26 +20,14 @@ describe('.get (specific go-ipfs features)', function () {
2120
data: fixture('test/fixtures/testfile.txt')
2221
}
2322

24-
let ipfsd
2523
let ipfs
2624

2725
before(async () => {
28-
ipfsd = await f.spawn({
29-
initOptions: {
30-
bits: 1024,
31-
profile: 'test'
32-
}
33-
})
34-
ipfs = ipfsClient(ipfsd.apiAddr)
35-
26+
ipfs = (await f.spawn()).api
3627
await ipfs.add(smallFile.data)
3728
})
3829

39-
after(async () => {
40-
if (ipfsd) {
41-
await ipfsd.stop()
42-
}
43-
})
30+
after(() => f.clean())
4431

4532
it('no compression args', async () => {
4633
const files = await ipfs.get(smallFile.cid)

0 commit comments

Comments
 (0)