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

Commit

Permalink
feat: js-ipfs 0.33.0 and go-ipfs 0.4.18
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Nov 4, 2018
1 parent e63c532 commit 4085089
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 54 deletions.
41 changes: 22 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"stream": "readable-stream"
},
"engines": {
"node": ">=6.0.0",
"npm": ">=3.0.0"
"node": ">=10.0.0",
"npm": ">6.0.0"
},
"scripts": {
"lint": "aegir lint",
Expand All @@ -35,36 +35,39 @@
},
"homepage": "https://github.com/ipfs/interop#readme",
"devDependencies": {
"aegir": "^15.1.0",
"aegir": "^17.0.1",
"async": "^2.6.1",
"bl": "^2.0.1",
"bl": "^2.1.2",
"bs58": "^4.0.1",
"buffer-loader": "~0.1.0",
"chai": "^4.1.2",
"cids": "~0.5.3",
"chai": "^4.2.0",
"cids": "~0.5.5",
"cross-env": "^5.2.0",
"detect-node": "^2.0.3",
"detect-node": "^2.0.4",
"dir-compare": "^1.4.0",
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react": "^7.11.1",
"expose-loader": "~0.7.5",
"form-data": "^2.3.2",
"go-ipfs-dep": "~0.4.17",
"form-data": "^2.3.3",
"go-ipfs-dep": "~0.4.18",
"hat": "0.0.3",
"ipfs": "~0.33.0-rc.2",
"ipfs-api": "^25.0.0",
"ipfs-unixfs": "~0.1.15",
"ipfsd-ctl": "~0.39.1",
"ipfs": "~0.33.0",
"ipfs-api": "^26.1.2",
"ipfs-unixfs": "~0.1.16",
"ipfsd-ctl": "~0.40.0",
"left-pad": "^1.3.0",
"libp2p-websocket-star-rendezvous": "~0.2.3",
"lodash": "^4.17.10",
"libp2p-websocket-star-rendezvous": "~0.2.4",
"lodash": "^4.17.11",
"mocha": "^5.2.0",
"ncp": "^2.0.0",
"pretty-bytes": "^5.1.0",
"random-fs": "^1.0.3",
"rimraf": "^2.6.2",
"stream-to-promise": "^2.2.0",
"transform-loader": "~0.2.4"
"transform-loader": "~0.2.4",
"is-ci": "^1.2.1"
},
"contributors": []
"contributors": [],
"dependencies": {
"is-os": "^1.0.1"
}
}
176 changes: 141 additions & 35 deletions test/exchange-files.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint max-nested-callbacks: ["error", 6] */
/* eslint-env mocha */
'use strict'

Expand All @@ -15,10 +16,10 @@ const randomFs = require('random-fs')
const promisify = require('promisify-es6')
const rimraf = require('rimraf')
const join = require('path').join
const os = require('os')
const hat = require('hat')

// const isWindows = os.platform() === 'win32'
const isCi = require('is-ci')
const isWindows = require('is-os').isWindows
const os = require('os')

const rmDir = promisify(rimraf)

Expand Down Expand Up @@ -47,40 +48,80 @@ const sizes = [
8 * MB,
64 * MB,
128 * MB
// 512 * MB,
// 512 * MB
// GB
// 10 * GB,
// 100 * GB,
// 1000 * GB
]

if (isCi) {
sizes.push(
// 512 * MB,
// GB
// 10 * GB,
// 100 * GB,
// 1000 * GB
)
}

const dirs = [
5,
10,
50
10
// 50,
// 100,
// 1000
// 1000,
// 10000
]

if (isCi) {
dirs.push(
// 50,
// 100,
// 1000
// 10000
)
}

const depth = [
5,
10
]

const timeout = 240 * 1000
if (isCi) {
depth.push(
// 100
// 1000
// 10000
)
}

const min = 60 * 1000
const timeout = isCi ? 15 * min : 5 * min

describe.skip('exchange files', () => {
describe('exchange files', () => {
let goDaemon
let goDaemon2
let jsDaemon
let js2Daemon
let jsDaemon2

let nodes

before(function (done) {
this.timeout(timeout)

parallel([
(cb) => goDf.spawn({ initOptions: { bits: 1024 } }, cb),
(cb) => goDf.spawn({ initOptions: { bits: 1024 } }, cb),
(cb) => jsDf.spawn({ type: 'js', initOptions: { bits: 512 } }, cb),
(cb) => jsDf.spawn({ type: 'js', initOptions: { bits: 512 } }, cb)
], (err, n) => {
expect(err).to.not.exist()
nodes = n
goDaemon = nodes[0]
jsDaemon = nodes[1]
js2Daemon = nodes[2]
goDaemon2 = nodes[1]
jsDaemon = nodes[2]
jsDaemon2 = nodes[3]
done()
})
})
Expand Down Expand Up @@ -121,7 +162,37 @@ describe.skip('exchange files', () => {
], done)
})

it('connect js <-> js', function (done) {
it('connect go <-> go2', function (done) {
this.timeout(timeout)

let goId
let go2Id

series([
(cb) => parallel([
(cb) => goDaemon.api.id(cb),
(cb) => goDaemon2.api.id(cb)
], (err, ids) => {
expect(err).to.not.exist()
goId = ids[0]
go2Id = ids[1]
cb()
}),
(cb) => goDaemon.api.swarm.connect(go2Id.addresses[0], cb),
(cb) => goDaemon2.api.swarm.connect(goId.addresses[0], cb),
(cb) => parallel([
(cb) => goDaemon.api.swarm.peers(cb),
(cb) => goDaemon2.api.swarm.peers(cb)
], (err, peers) => {
expect(err).to.not.exist()
expect(peers[0].map((p) => p.peer.toB58String())).to.include(go2Id.id)
expect(peers[1].map((p) => p.peer.toB58String())).to.include(goId.id)
cb()
})
], done)
})

it('connect js <-> js2', function (done) {
this.timeout(timeout)

let jsId
Expand All @@ -130,17 +201,17 @@ describe.skip('exchange files', () => {
series([
(cb) => parallel([
(cb) => jsDaemon.api.id(cb),
(cb) => js2Daemon.api.id(cb)
(cb) => jsDaemon2.api.id(cb)
], (err, ids) => {
expect(err).to.not.exist()
jsId = ids[0]
js2Id = ids[1]
cb()
}),
(cb) => js2Daemon.api.swarm.connect(jsId.addresses[0], cb),
(cb) => jsDaemon2.api.swarm.connect(jsId.addresses[0], cb),
(cb) => jsDaemon.api.swarm.connect(js2Id.addresses[0], cb),
(cb) => parallel([
(cb) => js2Daemon.api.swarm.peers(cb),
(cb) => jsDaemon2.api.swarm.peers(cb),
(cb) => jsDaemon.api.swarm.peers(cb)
], (err, peers) => {
expect(err).to.not.exist()
Expand All @@ -162,7 +233,7 @@ describe.skip('exchange files', () => {
(res, cb) => jsDaemon.api.cat(res[0].hash, cb)
], (err, file) => {
expect(err).to.not.exist()
expect(file).to.be.eql(data)
expect(file).to.eql(data)
done()
})
})
Expand All @@ -177,85 +248,120 @@ describe.skip('exchange files', () => {
(res, cb) => goDaemon.api.cat(res[0].hash, cb)
], (err, file) => {
expect(err).to.not.exist()
expect(file).to.be.eql(data)
expect(file).to.eql(data)
done()
})
})

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

const data = crypto.randomBytes(size)

waterfall([
(cb) => js2Daemon.api.add(data, cb),
(cb) => jsDaemon2.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb)
], (err, file) => {
expect(err).to.not.exist()
expect(file).to.be.eql(data)
expect(file).to.eql(data)
done()
})
})

it(`go -> go2: ${pretty(size)}`, function (done) {
this.timeout(timeout)

const data = crypto.randomBytes(size)

waterfall([
(cb) => goDaemon.api.add(data, cb),
(res, cb) => goDaemon2.api.cat(res[0].hash, cb)
], (err, file) => {
expect(err).to.not.exist()
expect(file).to.eql(data)
done()
})
})
}))

// TODO these tests are not fetching the full dir??
describe('get directory', () => dirs.forEach((num) => {
it(`go -> js: depth: 5, num: ${num}`, function () {
if (isWindows) { return }
// TODO fix dir tests on Windows

describe('get directory', () => depth.forEach((d) => dirs.forEach((num) => {
it(`go -> js: depth: ${d}, num: ${num}`, function () {
this.timeout(timeout)

const dir = tmpDir()

return randomFs({
path: dir,
depth: 5,
depth: d,
number: num
}).then(() => {
return goDaemon.api.util.addFromFs(dir, { recursive: true })
}).then((res) => {
const hash = res[res.length - 1].hash
return jsDaemon.api.object.get(hash)
return jsDaemon.api.files.get(hash)
}).then((res) => {
expect(res).to.exist()
return rmDir(dir)
})
})

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

const dir = tmpDir()
return randomFs({
path: dir,
depth: 5,
depth: d,
number: num
}).then(() => {
return jsDaemon.api.util.addFromFs(dir, { recursive: true })
}).then((res) => {
const hash = res[res.length - 1].hash
return goDaemon.api.object.get(hash)
return goDaemon.api.files.get(hash)
}).then((res) => {
expect(res).to.exist()
return rmDir(dir)
})
})

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

const dir = tmpDir()
return randomFs({
path: dir,
depth: 5,
depth: d,
number: num
}).then(() => {
return js2Daemon.api.util.addFromFs(dir, { recursive: true })
return jsDaemon2.api.util.addFromFs(dir, { recursive: true })
}).then((res) => {
const hash = res[res.length - 1].hash
return jsDaemon.api.object.get(hash)
return jsDaemon.api.files.get(hash)
}).then((res) => {
expect(res).to.exist()
return rmDir(dir)
})
})
}))

it(`go -> go2: depth: ${d}, num: ${num}`, function () {
this.timeout(timeout)

const dir = tmpDir()
return randomFs({
path: dir,
depth: d,
number: num
}).then(() => {
return goDaemon2.api.util.addFromFs(dir, { recursive: true })
}).then((res) => {
const hash = res[res.length - 1].hash
return goDaemon.api.files.get(hash)
}).then((res) => {
expect(res).to.exist()
return rmDir(dir)
})
})
})))
})

0 comments on commit 4085089

Please sign in to comment.