Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
chore: more clean up
  • Loading branch information
daviddias committed Nov 8, 2017
commit 61e1266a6e68e7bab568f0cf8127660d7c10f43c
8 changes: 4 additions & 4 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const parallel = require('async/parallel')
const spawnTools = require('./test/utils/spawn-tools')
const js = spawnTools.spawnJsNode
// const go = spawnTools.spawnGoNode
const stop = spawnTools.stopNodes
const ads = require('./test/utils/another-daemon-spawner')
const js = ads.spawnJsNode
// const go = ads.spawnGoNode
const stop = ads.stopNodes

/*
* spawns a daemon with ports numbers starting in 10 and ending in `num`
Expand Down
8 changes: 7 additions & 1 deletion test/interop/browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* eslint-env mocha */
'use strict'

describe.skip('browser interop test', () => {})
describe('browser interop tests', () => {
it('need to get written', function (done) {
this.timeout(10 * 1000)
// for teardown time
setTimeout(done, 5 * 1000)
})
})
8 changes: 4 additions & 4 deletions test/interop/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const waterfall = require('async/waterfall')
const multiaddr = require('multiaddr')
const crypto = require('crypto')

const spawnTools = require('./test/utils/spawn-tools')
const js = spawnTools.spawnJsNode
const go = spawnTools.spawnGoNode
const stop = spawnTools.stopNodes
const ads = require('../utils/another-daemon-spawner')
const js = ads.spawnJsNode
const go = ads.spawnGoNode
const stop = ads.stopNodes

describe.skip('circuit interop', function () {
let jsTCP
Expand Down
9 changes: 5 additions & 4 deletions test/interop/exchange-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const rmDir = promisify(rimraf)

const tmpDir = require('./util').tmpDir

const GoDaemon = require('./spawner/go')
const JsDaemon = require('./spawner/js')
const GoDaemon = require('../utils/interop-daemon-spawner/go')
const JsDaemon = require('../utils/interop-daemon-spawner/js')

const sizes = [
1024,
Expand All @@ -42,12 +42,13 @@ const dirs = [
100
]

describe('basic', () => {
describe.only('exchange files', () => {
let goDaemon
let jsDaemon
let js2Daemon

before((done) => {
before(function (done) {
this.timeout(15 * 1000)
goDaemon = new GoDaemon()
jsDaemon = new JsDaemon({port: 1})
js2Daemon = new JsDaemon({port: 2})
Expand Down
4 changes: 2 additions & 2 deletions test/interop/kad-dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const parallel = require('async/parallel')
const waterfall = require('async/waterfall')
const bl = require('bl')

const GODaemon = require('./spawner/go')
const JSDaemon = require('./spawner/js')
const GODaemon = require('../utils/interop-daemon-spawner/go')
const JSDaemon = require('../utils/interop-daemon-spawner/js')

describe.skip('kad-dht', () => {
describe('a JS node in the land of Go', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/interop/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const bl = require('bl')
const crypto = require('crypto')
const os = require('os')

const GoDaemon = require('./spawner/go')
const JsDaemon = require('./spawner/js')
const GoDaemon = require('../utils/interop-daemon-spawner/go')
const JsDaemon = require('../utils/interop-daemon-spawner/js')

function catAndCheck (daemon, hash, data, callback) {
waterfall([
Expand Down
68 changes: 32 additions & 36 deletions test/utils/spawn-tools.js → test/utils/another-daemon-spawner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ const waterfall = require('async/waterfall')
const series = require('async/series')

const relayConfig = require('./ipfs-factory-daemon/default-config.json')
const GoDaemon = require('../interop/spawner/go')
const Factory = require('./ipfs-factory-daemon')
const GoDaemon = require('./interop-daemon-spawner/go')

const nodes = []
const factory = new Factory()
exports = module.exports

exports.spawnGoNode = (addrs, hop, api, gateway, cb) => {
exports.spawnGoNode = (addrs, hop, api, gateway, callback) => {
if (typeof hop === 'function') {
cb = hop
callback = hop
hop = false
}
if (typeof api === 'function') {
cb = api
callback = api
api = 0
}
if (typeof gateway === 'function') {
cb = gateway
callback = gateway
gateway = 0
}

Expand Down Expand Up @@ -51,71 +51,67 @@ exports.spawnGoNode = (addrs, hop, api, gateway, cb) => {

daemon.start((err) => {
if (err) {
return cb(err)
return callback(err)
}
daemon.api.id((err, id) => {
if (err) {
return cb(err)
return callback(err)
}
nodes.push(daemon)
cb(null, daemon, id.addresses)
callback(null, daemon, id.addresses)
})
})
}

exports.spawnJsNode = (addrs, hop, api, gateway, cb) => {
exports.spawnJsNode = (addrs, hop, api, gateway, callback) => {
let relayPeer
let relayAddrs

if (typeof hop === 'function') {
cb = hop
callback = hop
hop = false
}
if (typeof api === 'function') {
cb = api
callback = api
api = 0
}
if (typeof gateway === 'function') {
cb = gateway
callback = gateway
gateway = 0
}

api = api || 0
gateway = gateway || 0

cb = cb || (() => {})
callback = callback || function noop () {}

waterfall([
(pCb) => {
factory.spawnNode(null,
Object.assign(relayConfig, {
Addresses: {
Swarm: addrs,
API: `/ip4/0.0.0.0/tcp/${api}`,
Gateway: `/ip4/0.0.0.0/tcp/${gateway}`
},
EXPERIMENTAL: {
Swarm: {
DisableRelay: false,
EnableRelayHop: hop
}
}
}), pCb)
},
(node, pCb) => {
(cb) => factory.spawnNode(null, Object.assign(relayConfig, {
Addresses: {
Swarm: addrs,
API: `/ip4/0.0.0.0/tcp/${api}`,
Gateway: `/ip4/0.0.0.0/tcp/${gateway}`
},
EXPERIMENTAL: {
Swarm: {
DisableRelay: false,
EnableRelayHop: hop
}
}
}), cb),
(node, cb) => {
relayPeer = node
pCb()
relayPeer.swarm.localAddrs(cb)
},
(pCb) => relayPeer.swarm.localAddrs(pCb),
(addrs, pCb) => {
(addrs, cb) => {
relayAddrs = addrs
pCb()
cb()
}
], (err) => {
if (err) {
return cb(err)
return callback(err)
}
cb(null, relayPeer, relayAddrs)
callback(null, relayPeer, relayAddrs)
})
}

Expand Down