Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit f5c267f

Browse files
author
Pedro Santos
committed
chore: update ipfsd-ctl version and use daemon.js util file
1 parent 647c1a0 commit f5c267f

17 files changed

+3134
-2248
lines changed

package-lock.json

+2,775-1,718
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"homepage": "https://github.com/ipfs/interop#readme",
4040
"dependencies": {
41-
"aegir": "^20.0.0",
41+
"aegir": "^20.3.1",
4242
"async": "^2.6.2",
4343
"base64url": "^3.0.0",
4444
"bl": "^3.0.0",
@@ -52,13 +52,13 @@
5252
"eslint-plugin-react": "^7.12.4",
5353
"expose-loader": "~0.7.5",
5454
"form-data": "^2.3.3",
55-
"go-ipfs-dep": "~0.4.20",
55+
"go-ipfs-dep": "~0.4.22",
5656
"hat": "~0.0.3",
57-
"ipfs": "^0.37.0",
58-
"ipfs-http-client": "^33.1.0",
57+
"ipfs": "^0.37.1",
58+
"ipfs-http-client": "^37.0.1",
5959
"ipfs-repo": "~0.26.6",
6060
"ipfs-unixfs": "~0.1.16",
61-
"ipfsd-ctl": "~0.42.4",
61+
"ipfsd-ctl": "~0.47.1",
6262
"ipns": "~0.5.1",
6363
"is-ci": "^2.0.0",
6464
"is-os": "^1.0.1",

test/cid-version-agnostic.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ const expect = chai.expect
77
chai.use(dirtyChai)
88
const hat = require('hat')
99
const CID = require('cids')
10-
const {
11-
spawnInitAndStartGoDaemon,
12-
spawnInitAndStartJsDaemon,
13-
stopDaemon
14-
} = require('./utils/daemon')
10+
const { spawnInitAndStartGoDaemon, spawnInitAndStartJsDaemon } = require('./utils/daemon')
11+
12+
const jsDaemonOptions = {
13+
config: {
14+
Bootstrap: []
15+
}
16+
}
1517

1618
describe('CID version agnostic', () => {
1719
const daemons = {}
@@ -20,8 +22,8 @@ describe('CID version agnostic', () => {
2022
this.timeout(50 * 1000)
2123

2224
const [js0, js1, go0, go1] = await Promise.all([
23-
spawnInitAndStartJsDaemon(),
24-
spawnInitAndStartJsDaemon(),
25+
spawnInitAndStartJsDaemon(jsDaemonOptions),
26+
spawnInitAndStartJsDaemon(jsDaemonOptions),
2527
spawnInitAndStartGoDaemon(),
2628
spawnInitAndStartGoDaemon()
2729
])
@@ -44,7 +46,7 @@ describe('CID version agnostic', () => {
4446

4547
after(function () {
4648
this.timeout(30 * 1000)
47-
return Promise.all(Object.values(daemons).map(stopDaemon))
49+
return Promise.all(Object.values(daemons).map((daemon) => daemon.stop()))
4850
})
4951

5052
it('should add v0 and cat v1 (go0 -> go0)', async () => {

test/circuit.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
const chai = require('chai')
66
const dirtyChai = require('dirty-chai')
7-
const expect = chai.expect
87
chai.use(dirtyChai)
98

10-
const parallel = require('async/parallel')
11-
129
const all = require('./circuit/all')
1310
const browser = require('./circuit/browser')
1411

@@ -45,18 +42,15 @@ describe('circuit', () => {
4542
dsc(test, function () {
4643
this.timeout(tests[test].timeout)
4744

48-
before((done) => {
49-
tests[test].create((err, _nodes) => {
50-
expect(err).to.not.exist()
51-
nodes = _nodes.map((n) => n.ipfsd)
52-
nodeA = _nodes[0]
53-
relay = _nodes[1]
54-
nodeB = _nodes[2]
55-
done()
56-
})
45+
before(async () => {
46+
const _nodes = await tests[test].create()
47+
nodes = _nodes.map((n) => n.ipfsd)
48+
nodeA = _nodes[0]
49+
relay = _nodes[1]
50+
nodeB = _nodes[2]
5751
})
5852

59-
after((done) => parallel(nodes.map((ipfsd) => (cb) => ipfsd.stop(cb)), done))
53+
after(() => Promise.all(nodes.map((node) => node.stop())))
6054

6155
it('connect', (done) => {
6256
tests[test].connect(nodeA, nodeB, relay, done)

test/circuit/all.js

+40-42
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
/* eslint-env mocha */
33
'use strict'
44

5-
const series = require('async/series')
6-
75
const utils = require('../utils/circuit')
86

97
const createJs = utils.createJsNode
@@ -13,59 +11,59 @@ const base = '/ip4/127.0.0.1/tcp/0'
1311

1412
module.exports = {
1513
'go-go-go': {
16-
create: (callback) => series([
17-
(cb) => createGo([`${base}/ws`], cb),
18-
(cb) => createGo([`${base}/ws`], cb),
19-
(cb) => createGo([`${base}/ws`], cb)
20-
], callback)
14+
create: () => Promise.all([
15+
createGo([`${base}/ws`]),
16+
createGo([`${base}/ws`]),
17+
createGo([`${base}/ws`])
18+
])
2119
},
2220
'js-go-go': {
23-
create: (callback) => series([
24-
(cb) => createJs([`${base}/ws`], cb),
25-
(cb) => createGo([`${base}/ws`], cb),
26-
(cb) => createGo([`${base}/ws`], cb)
27-
], callback)
21+
create: () => Promise.all([
22+
createJs([`${base}/ws`]),
23+
createGo([`${base}/ws`]),
24+
createGo([`${base}/ws`])
25+
])
2826
},
2927
'go-go-js': {
30-
create: (callback) => series([
31-
(cb) => createGo([`${base}/ws`], cb),
32-
(cb) => createGo([`${base}/ws`], cb),
33-
(cb) => createJs([`${base}/ws`], cb)
34-
], callback)
28+
create: () => Promise.all([
29+
createGo([`${base}/ws`]),
30+
createGo([`${base}/ws`]),
31+
createJs([`${base}/ws`])
32+
])
3533
},
3634
'js-go-js': {
37-
create: (callback) => series([
38-
(cb) => createJs([`${base}/ws`], cb),
39-
(cb) => createGo([`${base}/ws`], cb),
40-
(cb) => createJs([`${base}/ws`], cb)
41-
], callback)
35+
create: () => Promise.all([
36+
createJs([`${base}/ws`]),
37+
createGo([`${base}/ws`]),
38+
createJs([`${base}/ws`])
39+
])
4240
},
4341
'go-js-go': {
44-
create: (callback) => series([
45-
(cb) => createGo([`${base}/ws`], cb),
46-
(cb) => createJs([`${base}/ws`], cb),
47-
(cb) => createGo([`${base}/ws`], cb)
48-
], callback)
42+
create: () => Promise.all([
43+
createGo([`${base}/ws`]),
44+
createJs([`${base}/ws`]),
45+
createGo([`${base}/ws`])
46+
])
4947
},
5048
'js-js-go': {
51-
create: (callback) => series([
52-
(cb) => createJs([`${base}/ws`], cb),
53-
(cb) => createJs([`${base}/ws`], cb),
54-
(cb) => createGo([`${base}/ws`], cb)
55-
], callback)
49+
create: () => Promise.all([
50+
createJs([`${base}/ws`]),
51+
createJs([`${base}/ws`]),
52+
createGo([`${base}/ws`])
53+
])
5654
},
5755
'go-js-js': {
58-
create: (callback) => series([
59-
(cb) => createGo([`${base}/ws`], cb),
60-
(cb) => createJs([`${base}/ws`], cb),
61-
(cb) => createJs([`${base}/ws`], cb)
62-
], callback)
56+
create: () => Promise.all([
57+
createGo([`${base}/ws`]),
58+
createJs([`${base}/ws`]),
59+
createJs([`${base}/ws`])
60+
])
6361
},
6462
'js-js-js': {
65-
create: (callback) => series([
66-
(cb) => createJs([`${base}/ws`], cb),
67-
(cb) => createJs([`${base}/ws`], cb),
68-
(cb) => createJs([`${base}/ws`], cb)
69-
], callback)
63+
create: () => Promise.all([
64+
createJs([`${base}/ws`]),
65+
createJs([`${base}/ws`]),
66+
createJs([`${base}/ws`])
67+
])
7068
}
7169
}

test/circuit/browser.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ module.exports = {
8686
'go-browser-browser': {
8787
create: (callback) => series([
8888
(cb) => createGo([`${base}/ws`], cb),
89-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
90-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb)
89+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb),
90+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb)
9191
], callback),
9292
connect: (nodeA, nodeB, relay, callback) => {
9393
series([
@@ -103,8 +103,8 @@ module.exports = {
103103
'js-browser-browser': {
104104
create: (callback) => series([
105105
(cb) => createJs([`${base}/ws`], cb),
106-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
107-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb)
106+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb),
107+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb)
108108
], callback),
109109
connect: (nodeA, nodeB, relay, callback) => {
110110
series([
@@ -118,8 +118,8 @@ module.exports = {
118118
},
119119
'browser-browser-go': {
120120
create: (callback) => series([
121-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
122-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
121+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb),
122+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb),
123123
(cb) => createGo([`${base}/ws`], cb)
124124
], callback),
125125
connect: (nodeA, nodeB, relay, callback) => {
@@ -134,8 +134,8 @@ module.exports = {
134134
},
135135
'browser-browser-js': {
136136
create: (callback) => series([
137-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
138-
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
137+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb),
138+
(cb) => createProc(['/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star'], cb),
139139
(cb) => createJs([`${base}/ws`], cb)
140140
], callback),
141141
connect: (nodeA, nodeB, relay, callback) => {

test/exchange-files.js

+14-43
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ const os = require('os')
2323

2424
const rmDir = promisify(rimraf)
2525

26-
const DaemonFactory = require('ipfsd-ctl')
27-
const goDf = DaemonFactory.create()
28-
const jsDf = DaemonFactory.create({ type: 'js' })
26+
const { spawnInitAndStartGoDaemon, spawnInitAndStartJsDaemon } = require('./utils/daemon')
2927

3028
function tmpDir () {
3129
return join(os.tmpdir(), `ipfs_${hat()}`)
@@ -99,41 +97,17 @@ if (isCi) {
9997
const min = 60 * 1000
10098
const timeout = isCi ? 8 * min : 5 * min
10199

102-
function createJs (cb) {
103-
jsDf.spawn({
104-
type: 'js',
105-
initOptions: { bits: 512 },
106-
config: {
107-
Bootstrap: [],
108-
Discovery: {
109-
MDNS: {
110-
Enabled: false
111-
}
112-
}
113-
}
114-
}, cb)
115-
}
116-
117-
function createGo (cb) {
118-
goDf.spawn({
119-
initOptions: { bits: 1024 },
120-
config: {
121-
Bootstrap: [],
122-
Discovery: {
123-
MDNS: {
124-
Enabled: false
125-
}
126-
}
127-
}
128-
}, cb)
100+
const jsDaemonOptions = {
101+
initOptions: { bits: 512 },
102+
config: { Bootstrap: [] }
129103
}
130104

131105
describe('exchange files', () => {
132106
const tests = {
133-
'go -> js': [createGo, createJs],
134-
'go -> go2': [createGo, createGo],
135-
'js -> go': [createJs, createGo],
136-
'js -> js2': [createJs, createJs]
107+
'go -> js': [() => spawnInitAndStartGoDaemon(), () => spawnInitAndStartJsDaemon(jsDaemonOptions)],
108+
'go -> go2': [() => spawnInitAndStartGoDaemon(), () => spawnInitAndStartGoDaemon()],
109+
'js -> go': [() => spawnInitAndStartJsDaemon(jsDaemonOptions), () => spawnInitAndStartGoDaemon()],
110+
'js -> js2': [() => spawnInitAndStartJsDaemon(jsDaemonOptions), () => spawnInitAndStartJsDaemon(jsDaemonOptions)]
137111
}
138112

139113
Object.keys(tests).forEach((name) => {
@@ -143,15 +117,12 @@ describe('exchange files', () => {
143117
let id1
144118
let id2
145119

146-
before('spawn nodes', function (done) {
120+
before('spawn nodes', async function () {
147121
this.timeout(timeout)
148122

149-
parallel(tests[name], (err, nodes) => {
150-
expect(err).to.not.exist()
151-
daemon1 = nodes[0]
152-
daemon2 = nodes[1]
153-
done()
154-
})
123+
const nodes = await Promise.all(tests[name].map(fn => fn()))
124+
daemon1 = nodes[0]
125+
daemon2 = nodes[1]
155126
})
156127

157128
before('connect', function (done) {
@@ -181,10 +152,10 @@ describe('exchange files', () => {
181152
], done)
182153
})
183154

184-
after('stop nodes', function (done) {
155+
after('stop nodes', function () {
185156
this.timeout(timeout)
186157

187-
parallel([daemon1, daemon2].map((node) => (cb) => node.stop(cb)), done)
158+
return Promise.all([daemon1, daemon2].map((node) => node.stop()))
188159
})
189160

190161
describe('cat file', () => sizes.forEach((size) => {

0 commit comments

Comments
 (0)