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

Feat/circuit relay #6

Merged
merged 50 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
81b1e99
feat: port to new ipfsd-ctl
dryajov Dec 21, 2017
7013f88
fix: removing factory
dryajov Dec 23, 2017
65295bf
feat: adopting latest changes to ipfsd-ctl
dryajov Jan 11, 2018
4052ffa
chore: upping ipfsd-ctl version
dryajov Jan 17, 2018
e444539
test: increase timeouts
dryajov Jan 17, 2018
21eaeac
test: fixing circuit tests
dryajov Jan 18, 2018
6cc1628
test: run kad-dht tests in browser
dryajov Jan 18, 2018
4b8907b
wip: adding browser relay tests
dryajov Jan 24, 2018
d40a5bf
increase timeouts
dryajov Jan 25, 2018
9243b65
feat: add missing circuit tests from node runs
dryajov Jan 27, 2018
7a62388
fix: avoid using default API and Gateway ports
dryajov Jan 29, 2018
c61c5fd
feat: adding go to js test
dryajov Jan 29, 2018
90b7320
fix: /ipv4 -> /ip4
dryajov Jan 29, 2018
e4e1790
fix: cant relay if both the relay and one of the nodes are browser
dryajov Jan 29, 2018
46f172f
test: skip `get directory` tests on windows
dryajov Jan 29, 2018
98a7d04
fix: skip repo tests on windows
dryajov Jan 29, 2018
e9e8f73
fix: skip browser tests in node
dryajov Jan 30, 2018
655be31
fix: remove repo tests from browser runs
dryajov Jan 30, 2018
9f91929
fix: timeouts
dryajov Jan 30, 2018
4dd9b5f
fix: timeouts
dryajov Jan 30, 2018
b124d28
feat: increase browser inactivity timeout to make windows hapy
dryajov Jan 30, 2018
d504b65
feat: adding all missing browser tests
dryajov Jan 30, 2018
e938f61
fix: use IPFS_REUSEPORT untille new version of go-ipfs is released
dryajov Feb 2, 2018
d02d608
experiment: remove individual timeouts to rule time out related failures
dryajov Feb 2, 2018
0af7ac5
tests: reworking
dryajov Feb 3, 2018
645bf5f
remove runaway only
dryajov Mar 3, 2018
08d168c
lint
dryajov Mar 3, 2018
14059ed
even better tests
dryajov Mar 3, 2018
4f7451f
test: connect browser nodes with tiemout
dryajov Mar 3, 2018
35253ac
parametrize timeouts
dryajov Mar 3, 2018
1a947d3
reenable skipped test
dryajov Mar 3, 2018
3bb68f9
skip go-browser-browser
dryajov Mar 4, 2018
7157e5d
timeout
dryajov Mar 5, 2018
6ff891e
cleanup based on review
dryajov Mar 6, 2018
e5f617a
fix: naming of funcs
dryajov Mar 6, 2018
59e6a85
fix: naming of funcs
dryajov Mar 6, 2018
e2a007f
split circuit tests
dryajov Mar 6, 2018
c29f3a9
chore: rename files
dryajov Mar 6, 2018
9e9c38c
increase timeout
dryajov Mar 6, 2018
d5dd246
fix: missing import
dryajov Mar 6, 2018
4b3ee06
chore: remove .only
dryajov Mar 6, 2018
efcb48e
chore: add TODO regarding CAN_HOP
dryajov Mar 6, 2018
51a7118
several small fixes
dryajov Mar 6, 2018
06a4b9f
fix: pass options
dryajov Mar 7, 2018
1c261a7
review last commit
dryajov Mar 7, 2018
650876d
chore: updated todo
dryajov Mar 7, 2018
26daf07
chore: up deps
dryajov Mar 17, 2018
2a686e4
fix: daemon type in tests
dryajov Mar 18, 2018
b0e669a
Merge branch 'master' into feat/circuit-relay
daviddias May 28, 2018
9a2efbc
test: skip circuit tests. waiting for go-ipfs 0.4.15
daviddias May 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
'use strict'

const createServer = require('ipfsd-ctl').createServer
const parallel = require('async/parallel')
const rendezvous = require('libp2p-websocket-star-rendezvous')

let rzserver

const server = createServer()
module.exports = {
Expand All @@ -16,8 +20,28 @@ module.exports = {
},
hooks: {
browser: {
pre: server.start.bind(server),
post: server.stop.bind(server)
pre: (done) => {
parallel([
(cb) => server.start(cb),
(cb) => {
rendezvous.start({
port: 24642
}, (err, _rzserver) => {
if (err) {
return done(err)
}
rzserver = _rzserver
cb()
})
}
], done)
},
post: (done) => {
parallel([
(cb) => server.stop(cb),
(cb) => rzserver.stop(cb)
], done)
}
}
}
}
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
},
"scripts": {
"lint": "aegir lint",
"test": "aegir test -t node -t browser --no-cors",
"test:node": "aegir test -t node -f test/node.js",
"test:browser": "aegir test -t browser --no-cors -f test/browser.js"
"test": "cross-env IPFS_REUSEPORT=false aegir test -t node -t browser --no-cors",
"test:node": "cross-env IPFS_REUSEPORT=false aegir test -t node -f test/node.js",
"test:browser": "cross-env IPFS_REUSEPORT=false aegir test -t browser --no-cors -f test/browser.js"
},
"pre-push": [
"lint"
Expand All @@ -44,7 +44,8 @@
"bs58": "^4.0.1",
"buffer-loader": "0.0.1",
"chai": "^4.1.2",
"cids": "^0.5.3",
"cross-env": "^5.1.3",
"cids": "~0.5.3",
"detect-node": "^2.0.3",
"dir-compare": "^1.4.0",
"dirty-chai": "^2.0.1",
Expand All @@ -53,12 +54,13 @@
"form-data": "^2.3.2",
"go-ipfs-dep": "^0.4.15",
"hat": "0.0.3",
"ipfs": "~0.28.2",
"ipfs-api": "^21.0.0",
"ipfsd-ctl": "~0.36.0",
"left-pad": "^1.3.0",
"lodash": "^4.17.10",
"mocha": "^5.1.1",
"ipfs": "~0.28.0",
"ipfs-api": "^18.1.1",
"ipfsd-ctl": "~0.30.3",
"left-pad": "^1.2.0",
"libp2p-websocket-star-rendezvous": "~0.2.2",
"lodash": "^4.17.4",
"mocha": "^4.0.1",
"ncp": "^2.0.0",
"pretty-bytes": "^5.0.0",
"random-fs": "^1.0.3",
Expand Down
3 changes: 2 additions & 1 deletion test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
// require('./exchange-files')
// require('./pubsub')
require('./kad-dht')
require('./repo')
require('./circuit')
// require('./repo')
66 changes: 66 additions & 0 deletions test/circuit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const parallel = require('async/parallel')

const all = require('./circuit/all')
const browser = require('./circuit/browser')

const isNode = require('detect-node')
const send = require('./utils/circuit').send
const connect = require('./utils/circuit').connect

const timeout = 80 * 1000
const baseTest = {
connect,
send,
timeout
}

// TODO: unskip once go-ipfs 0.4.15 is out
describe.skip('circuit', () => {
const tests = all
if (!isNode) {
Object.assign(tests, browser)
}

Object.keys(tests).forEach((test) => {
let nodes
let nodeA
let relay
let nodeB

tests[test] = Object.assign({}, baseTest, tests[test])
const dsc = tests[test].skip && tests[test].skip() ? describe.skip : describe
dsc(test, function () {
this.timeout(tests[test].timeout)

before((done) => {
tests[test].create((err, _nodes) => {
expect(err).to.not.exist()
nodes = _nodes.map((n) => n.ipfsd)
nodeA = _nodes[0]
relay = _nodes[1]
nodeB = _nodes[2]
done()
})
})

after((done) => parallel(nodes.map((ipfsd) => (cb) => ipfsd.stop(cb)), done))

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

it('send', (done) => {
tests[test].send(nodeA.ipfsd.api, nodeB.ipfsd.api, done)
})
})
})
})
71 changes: 71 additions & 0 deletions test/circuit/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
'use strict'

const series = require('async/series')

const utils = require('../utils/circuit')

const createJs = utils.createJsNode
const createGo = utils.createGoNode

const base = '/ip4/127.0.0.1/tcp/0'

module.exports = {
'go-go-go': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb)
], callback)
},
'js-go-go': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb)
], callback)
},
'go-go-js': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback)
},
'js-go-js': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback)
},
'go-js-go': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb)
], callback)
},
'js-js-go': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb)
], callback)
},
'go-js-js': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback)
},
'js-js-js': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback)
}
}
155 changes: 155 additions & 0 deletions test/circuit/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/* eslint max-nested-callbacks: ["error", 8] */
/* eslint-env mocha */
'use strict'

const series = require('async/series')

const utils = require('../utils/circuit')

const createJs = utils.createJsNode
const createProc = utils.createProcNode
const createGo = utils.createGoNode
const connWithTimeout = utils.connWithTimeout

const getWsAddr = utils.getWsAddr
const getWsStarAddr = utils.getWsStarAddr
const getCircuitAddr = utils.getCircuitAddr

const base = '/ip4/127.0.0.1/tcp/0'

module.exports = {
'browser-go-js': {
create:
(callback) => series([
(cb) => createProc([], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback),
connect: connWithTimeout(1500)
},
'browser-go-go': {
create: (callback) => series([
(cb) => createProc([], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb)
], callback),
connect: connWithTimeout(1500)
},
'browser-js-js': {
create: (callback) => series([
(cb) => createProc([], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback),
connect: connWithTimeout(1500)
},
'browser-js-go': {
create: (callback) => series([
(cb) => createProc([], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback),
connect: connWithTimeout(1500)
},
'js-go-browser': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createProc([], cb)
], callback),
connect: connWithTimeout(1500)
},
'go-go-browser': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createGo([`${base}/ws`], cb),
(cb) => createProc([], cb)
], callback),
connect: connWithTimeout(1500)
},
'js-js-browser': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createProc([], cb)
], callback),
connect: connWithTimeout(1500)
},
'go-js-browser': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createJs([`${base}/ws`], cb),
(cb) => createProc([], cb)
], callback),
connect: connWithTimeout(1500)
},
'go-browser-browser': {
create: (callback) => series([
(cb) => createGo([`${base}/ws`], cb),
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb)
], callback),
connect: (nodeA, nodeB, relay, callback) => {
series([
(cb) => relay.ipfsd.api.swarm.connect(getWsAddr(nodeA.addrs), cb),
(cb) => relay.ipfsd.api.swarm.connect(getWsStarAddr(nodeB.addrs), cb),
// TODO: needed until https://github.com/ipfs/interop/issues/17 is resolved
(cb) => setTimeout(cb, 5000),
(cb) => nodeA.ipfsd.api.swarm.connect(getCircuitAddr(nodeB.addrs), cb)
], callback)
},
timeout: 100 * 1000,
skip: () => false
},
'js-browser-browser': {
create: (callback) => series([
(cb) => createJs([`${base}/ws`], cb),
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb)
], callback),
connect: (nodeA, nodeB, relay, callback) => {
series([
(cb) => relay.ipfsd.api.swarm.connect(getWsAddr(nodeA.addrs), cb),
(cb) => relay.ipfsd.api.swarm.connect(getWsStarAddr(nodeB.addrs), cb),
// TODO: needed until https://github.com/ipfs/interop/issues/17 is resolved
(cb) => setTimeout(cb, 3000),
(cb) => nodeA.ipfsd.api.swarm.connect(getCircuitAddr(nodeB.addrs), cb)
], callback)
},
timeout: 100 * 1000
},
'browser-browser-go': {
create: (callback) => series([
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
(cb) => createGo([`${base}/ws`], cb)
], callback),
connect: (nodeA, nodeB, relay, callback) => {
series([
(cb) => relay.ipfsd.api.swarm.connect(getWsStarAddr(nodeA.addrs), cb),
(cb) => relay.ipfsd.api.swarm.connect(getWsAddr(nodeB.addrs), cb),
// TODO: needed until https://github.com/ipfs/interop/issues/17 is resolved
(cb) => setTimeout(cb, 5000),
(cb) => nodeA.ipfsd.api.swarm.connect(getCircuitAddr(nodeB.addrs), cb)
], callback)
},
timeout: 100 * 1000,
skip: () => true
},
'browser-browser-js': {
create: (callback) => series([
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
(cb) => createProc([`/ip4/127.0.0.1/tcp/24642/ws/p2p-websocket-star`], cb),
(cb) => createJs([`${base}/ws`], cb)
], callback),
connect: (nodeA, nodeB, relay, callback) => {
series([
(cb) => relay.ipfsd.api.swarm.connect(getWsStarAddr(nodeA.addrs), cb),
(cb) => relay.ipfsd.api.swarm.connect(getWsAddr(nodeB.addrs), cb),
// TODO: needed until https://github.com/ipfs/interop/issues/17 is resolved
(cb) => setTimeout(cb, 3000),
(cb) => nodeA.ipfsd.api.swarm.connect(getCircuitAddr(nodeB.addrs), cb)
], callback)
}
}
}
Loading