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

Commit 4085089

Browse files
committed
feat: js-ipfs 0.33.0 and go-ipfs 0.4.18
1 parent e63c532 commit 4085089

File tree

2 files changed

+163
-54
lines changed

2 files changed

+163
-54
lines changed

package.json

+22-19
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"stream": "readable-stream"
1313
},
1414
"engines": {
15-
"node": ">=6.0.0",
16-
"npm": ">=3.0.0"
15+
"node": ">=10.0.0",
16+
"npm": ">6.0.0"
1717
},
1818
"scripts": {
1919
"lint": "aegir lint",
@@ -35,36 +35,39 @@
3535
},
3636
"homepage": "https://github.com/ipfs/interop#readme",
3737
"devDependencies": {
38-
"aegir": "^15.1.0",
38+
"aegir": "^17.0.1",
3939
"async": "^2.6.1",
40-
"bl": "^2.0.1",
40+
"bl": "^2.1.2",
4141
"bs58": "^4.0.1",
42-
"buffer-loader": "~0.1.0",
43-
"chai": "^4.1.2",
44-
"cids": "~0.5.3",
42+
"chai": "^4.2.0",
43+
"cids": "~0.5.5",
4544
"cross-env": "^5.2.0",
46-
"detect-node": "^2.0.3",
45+
"detect-node": "^2.0.4",
4746
"dir-compare": "^1.4.0",
4847
"dirty-chai": "^2.0.1",
49-
"eslint-plugin-react": "^7.10.0",
48+
"eslint-plugin-react": "^7.11.1",
5049
"expose-loader": "~0.7.5",
51-
"form-data": "^2.3.2",
52-
"go-ipfs-dep": "~0.4.17",
50+
"form-data": "^2.3.3",
51+
"go-ipfs-dep": "~0.4.18",
5352
"hat": "0.0.3",
54-
"ipfs": "~0.33.0-rc.2",
55-
"ipfs-api": "^25.0.0",
56-
"ipfs-unixfs": "~0.1.15",
57-
"ipfsd-ctl": "~0.39.1",
53+
"ipfs": "~0.33.0",
54+
"ipfs-api": "^26.1.2",
55+
"ipfs-unixfs": "~0.1.16",
56+
"ipfsd-ctl": "~0.40.0",
5857
"left-pad": "^1.3.0",
59-
"libp2p-websocket-star-rendezvous": "~0.2.3",
60-
"lodash": "^4.17.10",
58+
"libp2p-websocket-star-rendezvous": "~0.2.4",
59+
"lodash": "^4.17.11",
6160
"mocha": "^5.2.0",
6261
"ncp": "^2.0.0",
6362
"pretty-bytes": "^5.1.0",
6463
"random-fs": "^1.0.3",
6564
"rimraf": "^2.6.2",
6665
"stream-to-promise": "^2.2.0",
67-
"transform-loader": "~0.2.4"
66+
"transform-loader": "~0.2.4",
67+
"is-ci": "^1.2.1"
6868
},
69-
"contributors": []
69+
"contributors": [],
70+
"dependencies": {
71+
"is-os": "^1.0.1"
72+
}
7073
}

test/exchange-files.js

+141-35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint max-nested-callbacks: ["error", 6] */
12
/* eslint-env mocha */
23
'use strict'
34

@@ -15,10 +16,10 @@ const randomFs = require('random-fs')
1516
const promisify = require('promisify-es6')
1617
const rimraf = require('rimraf')
1718
const join = require('path').join
18-
const os = require('os')
1919
const hat = require('hat')
20-
21-
// const isWindows = os.platform() === 'win32'
20+
const isCi = require('is-ci')
21+
const isWindows = require('is-os').isWindows
22+
const os = require('os')
2223

2324
const rmDir = promisify(rimraf)
2425

@@ -47,40 +48,80 @@ const sizes = [
4748
8 * MB,
4849
64 * MB,
4950
128 * MB
50-
// 512 * MB,
51+
// 512 * MB
5152
// GB
53+
// 10 * GB,
54+
// 100 * GB,
55+
// 1000 * GB
5256
]
5357

58+
if (isCi) {
59+
sizes.push(
60+
// 512 * MB,
61+
// GB
62+
// 10 * GB,
63+
// 100 * GB,
64+
// 1000 * GB
65+
)
66+
}
67+
5468
const dirs = [
5569
5,
56-
10,
57-
50
70+
10
71+
// 50,
5872
// 100,
59-
// 1000
73+
// 1000,
74+
// 10000
75+
]
76+
77+
if (isCi) {
78+
dirs.push(
79+
// 50,
80+
// 100,
81+
// 1000
82+
// 10000
83+
)
84+
}
85+
86+
const depth = [
87+
5,
88+
10
6089
]
6190

62-
const timeout = 240 * 1000
91+
if (isCi) {
92+
depth.push(
93+
// 100
94+
// 1000
95+
// 10000
96+
)
97+
}
98+
99+
const min = 60 * 1000
100+
const timeout = isCi ? 15 * min : 5 * min
63101

64-
describe.skip('exchange files', () => {
102+
describe('exchange files', () => {
65103
let goDaemon
104+
let goDaemon2
66105
let jsDaemon
67-
let js2Daemon
106+
let jsDaemon2
68107

69108
let nodes
70109

71110
before(function (done) {
72111
this.timeout(timeout)
73112

74113
parallel([
114+
(cb) => goDf.spawn({ initOptions: { bits: 1024 } }, cb),
75115
(cb) => goDf.spawn({ initOptions: { bits: 1024 } }, cb),
76116
(cb) => jsDf.spawn({ type: 'js', initOptions: { bits: 512 } }, cb),
77117
(cb) => jsDf.spawn({ type: 'js', initOptions: { bits: 512 } }, cb)
78118
], (err, n) => {
79119
expect(err).to.not.exist()
80120
nodes = n
81121
goDaemon = nodes[0]
82-
jsDaemon = nodes[1]
83-
js2Daemon = nodes[2]
122+
goDaemon2 = nodes[1]
123+
jsDaemon = nodes[2]
124+
jsDaemon2 = nodes[3]
84125
done()
85126
})
86127
})
@@ -121,7 +162,37 @@ describe.skip('exchange files', () => {
121162
], done)
122163
})
123164

124-
it('connect js <-> js', function (done) {
165+
it('connect go <-> go2', function (done) {
166+
this.timeout(timeout)
167+
168+
let goId
169+
let go2Id
170+
171+
series([
172+
(cb) => parallel([
173+
(cb) => goDaemon.api.id(cb),
174+
(cb) => goDaemon2.api.id(cb)
175+
], (err, ids) => {
176+
expect(err).to.not.exist()
177+
goId = ids[0]
178+
go2Id = ids[1]
179+
cb()
180+
}),
181+
(cb) => goDaemon.api.swarm.connect(go2Id.addresses[0], cb),
182+
(cb) => goDaemon2.api.swarm.connect(goId.addresses[0], cb),
183+
(cb) => parallel([
184+
(cb) => goDaemon.api.swarm.peers(cb),
185+
(cb) => goDaemon2.api.swarm.peers(cb)
186+
], (err, peers) => {
187+
expect(err).to.not.exist()
188+
expect(peers[0].map((p) => p.peer.toB58String())).to.include(go2Id.id)
189+
expect(peers[1].map((p) => p.peer.toB58String())).to.include(goId.id)
190+
cb()
191+
})
192+
], done)
193+
})
194+
195+
it('connect js <-> js2', function (done) {
125196
this.timeout(timeout)
126197

127198
let jsId
@@ -130,17 +201,17 @@ describe.skip('exchange files', () => {
130201
series([
131202
(cb) => parallel([
132203
(cb) => jsDaemon.api.id(cb),
133-
(cb) => js2Daemon.api.id(cb)
204+
(cb) => jsDaemon2.api.id(cb)
134205
], (err, ids) => {
135206
expect(err).to.not.exist()
136207
jsId = ids[0]
137208
js2Id = ids[1]
138209
cb()
139210
}),
140-
(cb) => js2Daemon.api.swarm.connect(jsId.addresses[0], cb),
211+
(cb) => jsDaemon2.api.swarm.connect(jsId.addresses[0], cb),
141212
(cb) => jsDaemon.api.swarm.connect(js2Id.addresses[0], cb),
142213
(cb) => parallel([
143-
(cb) => js2Daemon.api.swarm.peers(cb),
214+
(cb) => jsDaemon2.api.swarm.peers(cb),
144215
(cb) => jsDaemon.api.swarm.peers(cb)
145216
], (err, peers) => {
146217
expect(err).to.not.exist()
@@ -162,7 +233,7 @@ describe.skip('exchange files', () => {
162233
(res, cb) => jsDaemon.api.cat(res[0].hash, cb)
163234
], (err, file) => {
164235
expect(err).to.not.exist()
165-
expect(file).to.be.eql(data)
236+
expect(file).to.eql(data)
166237
done()
167238
})
168239
})
@@ -177,85 +248,120 @@ describe.skip('exchange files', () => {
177248
(res, cb) => goDaemon.api.cat(res[0].hash, cb)
178249
], (err, file) => {
179250
expect(err).to.not.exist()
180-
expect(file).to.be.eql(data)
251+
expect(file).to.eql(data)
181252
done()
182253
})
183254
})
184255

185-
it(`js -> js: ${pretty(size)}`, function (done) {
256+
it(`js -> js2: ${pretty(size)}`, function (done) {
186257
this.timeout(timeout)
187258

188259
const data = crypto.randomBytes(size)
189260

190261
waterfall([
191-
(cb) => js2Daemon.api.add(data, cb),
262+
(cb) => jsDaemon2.api.add(data, cb),
192263
(res, cb) => jsDaemon.api.cat(res[0].hash, cb)
193264
], (err, file) => {
194265
expect(err).to.not.exist()
195-
expect(file).to.be.eql(data)
266+
expect(file).to.eql(data)
267+
done()
268+
})
269+
})
270+
271+
it(`go -> go2: ${pretty(size)}`, function (done) {
272+
this.timeout(timeout)
273+
274+
const data = crypto.randomBytes(size)
275+
276+
waterfall([
277+
(cb) => goDaemon.api.add(data, cb),
278+
(res, cb) => goDaemon2.api.cat(res[0].hash, cb)
279+
], (err, file) => {
280+
expect(err).to.not.exist()
281+
expect(file).to.eql(data)
196282
done()
197283
})
198284
})
199285
}))
200286

201-
// TODO these tests are not fetching the full dir??
202-
describe('get directory', () => dirs.forEach((num) => {
203-
it(`go -> js: depth: 5, num: ${num}`, function () {
287+
if (isWindows) { return }
288+
// TODO fix dir tests on Windows
289+
290+
describe('get directory', () => depth.forEach((d) => dirs.forEach((num) => {
291+
it(`go -> js: depth: ${d}, num: ${num}`, function () {
204292
this.timeout(timeout)
205293

206294
const dir = tmpDir()
207-
208295
return randomFs({
209296
path: dir,
210-
depth: 5,
297+
depth: d,
211298
number: num
212299
}).then(() => {
213300
return goDaemon.api.util.addFromFs(dir, { recursive: true })
214301
}).then((res) => {
215302
const hash = res[res.length - 1].hash
216-
return jsDaemon.api.object.get(hash)
303+
return jsDaemon.api.files.get(hash)
217304
}).then((res) => {
218305
expect(res).to.exist()
219306
return rmDir(dir)
220307
})
221308
})
222309

223-
it(`js -> go: depth: 5, num: ${num}`, function () {
310+
it(`js -> go: depth: ${d}, num: ${num}`, function () {
224311
this.timeout(timeout)
225312

226313
const dir = tmpDir()
227314
return randomFs({
228315
path: dir,
229-
depth: 5,
316+
depth: d,
230317
number: num
231318
}).then(() => {
232319
return jsDaemon.api.util.addFromFs(dir, { recursive: true })
233320
}).then((res) => {
234321
const hash = res[res.length - 1].hash
235-
return goDaemon.api.object.get(hash)
322+
return goDaemon.api.files.get(hash)
236323
}).then((res) => {
237324
expect(res).to.exist()
238325
return rmDir(dir)
239326
})
240327
})
241328

242-
it(`js -> js: depth: 5, num: ${num}`, function () {
329+
it(`js -> js2: depth: ${d}, num: ${num}`, function () {
243330
this.timeout(timeout)
244331

245332
const dir = tmpDir()
246333
return randomFs({
247334
path: dir,
248-
depth: 5,
335+
depth: d,
249336
number: num
250337
}).then(() => {
251-
return js2Daemon.api.util.addFromFs(dir, { recursive: true })
338+
return jsDaemon2.api.util.addFromFs(dir, { recursive: true })
252339
}).then((res) => {
253340
const hash = res[res.length - 1].hash
254-
return jsDaemon.api.object.get(hash)
341+
return jsDaemon.api.files.get(hash)
255342
}).then((res) => {
256343
expect(res).to.exist()
257344
return rmDir(dir)
258345
})
259346
})
260-
}))
347+
348+
it(`go -> go2: depth: ${d}, num: ${num}`, function () {
349+
this.timeout(timeout)
350+
351+
const dir = tmpDir()
352+
return randomFs({
353+
path: dir,
354+
depth: d,
355+
number: num
356+
}).then(() => {
357+
return goDaemon2.api.util.addFromFs(dir, { recursive: true })
358+
}).then((res) => {
359+
const hash = res[res.length - 1].hash
360+
return goDaemon.api.files.get(hash)
361+
}).then((res) => {
362+
expect(res).to.exist()
363+
return rmDir(dir)
364+
})
365+
})
366+
})))
261367
})

0 commit comments

Comments
 (0)