This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
517 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
Oops, something went wrong.