From 38730b92eaba75f494dd5b282a5495ef63a9a2fe Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 3 Oct 2018 16:35:43 +0100 Subject: [PATCH] chore: refactored interop tests --- package.json | 7 +- test/browser.js | 2 +- test/kad-dht.js | 733 +++++++++++++++++++++++++----------------------- 3 files changed, 385 insertions(+), 357 deletions(-) diff --git a/package.json b/package.json index e1ab5531..c5d7de2f 100644 --- a/package.json +++ b/package.json @@ -52,10 +52,10 @@ "form-data": "^2.3.2", "go-ipfs-dep": "~0.4.17", "hat": "0.0.3", - "ipfs": "~0.33.0-rc.2", + "ipfs": "ipfs/js-ipfs#feat/dht-part-ii", "ipfs-api": "^25.0.0", "ipfs-unixfs": "~0.1.15", - "ipfsd-ctl": "~0.39.1", + "ipfsd-ctl": "~0.39.5", "left-pad": "^1.3.0", "libp2p-websocket-star-rendezvous": "~0.2.3", "lodash": "^4.17.10", @@ -67,5 +67,6 @@ "stream-to-promise": "^2.2.0", "transform-loader": "~0.2.4" }, - "contributors": [] + "contributors": [], + "dependencies": {} } diff --git a/test/browser.js b/test/browser.js index 3cb6ce16..ae48adfe 100644 --- a/test/browser.js +++ b/test/browser.js @@ -3,7 +3,7 @@ // require('./exchange-files') // require('./pubsub') -require('./kad-dht') +// require('./kad-dht') require('./circuit') // require('./repo') require('./files') diff --git a/test/kad-dht.js b/test/kad-dht.js index ff48125c..1470b949 100644 --- a/test/kad-dht.js +++ b/test/kad-dht.js @@ -1,3 +1,4 @@ +/* eslint max-nested-callbacks: ["error", 6] */ /* eslint-env mocha */ 'use strict' @@ -8,14 +9,14 @@ const expect = chai.expect chai.use(dirtyChai) chai.use(chaiBytes) -const series = require('async/series') const crypto = require('crypto') const parallel = require('async/parallel') -const waterfall = require('async/waterfall') const DaemonFactory = require('ipfsd-ctl') +const IPFS = require('ipfs') const goDf = DaemonFactory.create() -const jsDf = DaemonFactory.create({ type: 'js' }) +const jsDf = DaemonFactory.create({ type: 'proc', exec: IPFS }) +// const jsDf = DaemonFactory.create({ type: 'js' }) CHANGE TO HERE once UPDATED const getConfig = (bootstrap) => ({ Bootstrap: bootstrap, @@ -44,7 +45,7 @@ const spawnJsDaemon = (bootstrap = [], callback) => { }, callback) } -const getNodeId = (node, callback) => { +const getBootstrapAddr = (node, callback) => { node.api.id((err, res) => { expect(err).to.not.exist() expect(res.id).to.exist() @@ -53,466 +54,492 @@ const getNodeId = (node, callback) => { }) } -describe.only('kad-dht', () => { - describe.only('a JS network', () => { - let bootstrapAddr - let node0 - let node1 - let node2 - let node3 - let data +const addFileAndCat = (addDaemon, catDaemons, data, callback) => { + addDaemon.api.files.add(data, (err, res) => { + expect(err).to.not.exist() + + parallel(catDaemons.map((daemon) => (cb) => daemon.api.files.cat(res[0].hash, cb)), (err, res) => { + expect(err).to.not.exist() + res.forEach((resData) => { + expect(resData).to.equalBytes(data) + }) + callback() + }) + }) +} - // spawn bootstrap daemon and get address - before(function (done) { - this.timeout(60 * 1000) +describe('kad-dht', () => { + describe('kad-dht with a single bootstrap node', () => { + describe('a JS network', () => { + let bootstrapAddr + let nodes = [] + let data = crypto.randomBytes(9001) - spawnJsDaemon([], (err, node) => { - expect(err).to.not.exist() - node0 = node + // spawn bootstrap daemon and get address + before(function (done) { + this.timeout(60 * 1000) - getNodeId(node0, (err, res) => { + spawnJsDaemon([], (err, node) => { expect(err).to.not.exist() - bootstrapAddr = res - done() + nodes.push(node) + + getBootstrapAddr(nodes[0], (err, res) => { + expect(err).to.not.exist() + bootstrapAddr = res + done() + }) }) }) - }) - // spawn daemons - before(function (done) { - this.timeout(70 * 1000) - const bootstrap = [bootstrapAddr] - - parallel([ - (cb) => spawnJsDaemon(bootstrap, cb), - (cb) => spawnJsDaemon(bootstrap, cb), - (cb) => spawnJsDaemon(bootstrap, cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - node3 = nodes[2] - done() + // spawn daemons + before(function (done) { + this.timeout(70 * 1000) + const bootstrap = [bootstrapAddr] + + parallel([ + (cb) => spawnJsDaemon(bootstrap, cb), + (cb) => spawnJsDaemon(bootstrap, cb), + (cb) => spawnJsDaemon(bootstrap, cb) + ], (err, spawnedNodes) => { + expect(err).to.not.exist() + spawnedNodes.forEach((node) => nodes.push(node)) + setTimeout(done, 25000) // Wait for peers to have each other on the DHT + }) }) - }) - // create data - before(function (done) { - data = crypto.randomBytes(9001) - done() - }) + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) + }) - after(function (done) { - this.timeout(100 * 1000) - series([ - (cb) => node1.stop(cb), - (cb) => node2.stop(cb), - (cb) => node3.stop(cb), - (cb) => node0.stop(cb) - ], done) + it('should get from the network after being added', function (done) { + this.timeout(100 * 1000) + addFileAndCat(nodes[1], [nodes[2], nodes[3]], data, done) + }) }) - it('should get from the network after being added', function (done) { - this.timeout(100 * 1000) + describe('a GO network', () => { + let bootstrapAddr + let nodes = [] + let data = crypto.randomBytes(9001) - node1.api.add(data, (err, res) => { - expect(err).to.not.exist() + // spawn bootstrap daemon and get address + before(function (done) { + this.timeout(60 * 1000) - parallel([ - (cb) => node2.api.cat(res[0].hash, cb), - (cb) => node3.api.cat(res[0].hash, cb) - ], (err, res) => { + spawnGoDaemon([], (err, node) => { expect(err).to.not.exist() - expect(res[0]).to.equalBytes(data) - expect(res[1]).to.equalBytes(data) - done() + nodes.push(node) + + getBootstrapAddr(nodes[0], (err, res) => { + expect(err).to.not.exist() + bootstrapAddr = res + done() + }) }) }) - }) - }) - - describe('a GO network', () => { - let bootstrapAddr - let node0 - let node1 - let node2 - let node3 - let data - - // spawn bootstrap daemon and get address - before(function (done) { - this.timeout(60 * 1000) - spawnGoDaemon([], (err, node) => { - expect(err).to.not.exist() - node0 = node + // spawn daemons + before(function (done) { + this.timeout(70 * 1000) + const bootstrap = [bootstrapAddr] - getNodeId(node0, (err, res) => { + parallel([ + (cb) => spawnGoDaemon(bootstrap, cb), + (cb) => spawnGoDaemon(bootstrap, cb), + (cb) => spawnGoDaemon(bootstrap, cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - bootstrapAddr = res - done() + spawnedNodes.forEach((node) => nodes.push(node)) + setTimeout(done, 25000) // Wait for peers to have each other on the DHT }) }) - }) - // spawn daemons - before(function (done) { - this.timeout(70 * 1000) - const bootstrap = [bootstrapAddr] - - parallel([ - (cb) => spawnGoDaemon(bootstrap, cb), - (cb) => spawnGoDaemon(bootstrap, cb), - (cb) => spawnGoDaemon(bootstrap, cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - node3 = nodes[2] - done() + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) }) - }) - // create data - before(function (done) { - data = crypto.randomBytes(9001) - done() + it('should get from the network after being added', function (done) { + this.timeout(60 * 1000) + addFileAndCat(nodes[1], [nodes[2], nodes[3]], data, done) + }) }) - after(function (done) { - this.timeout(100 * 1000) - series([ - (cb) => node1.stop(cb), - (cb) => node2.stop(cb), - (cb) => node3.stop(cb), - (cb) => node0.stop(cb) - ], done) - }) + describe('a JS bootstrap node in the land of Go', () => { + let bootstrapAddr + let nodes = [] + let data = crypto.randomBytes(9001) - it('should get from the network after being added', function (done) { - this.timeout(60 * 1000) + // spawn bootstrap daemon and get address + before(function (done) { + this.timeout(60 * 1000) - node1.api.add(data, (err, res) => { - expect(err).to.not.exist() + spawnJsDaemon([], (err, node) => { + expect(err).to.not.exist() + nodes.push(node) + + getBootstrapAddr(nodes[0], (err, res) => { + expect(err).to.not.exist() + bootstrapAddr = res + done() + }) + }) + }) + + // spawn daemons + before(function (done) { + this.timeout(70 * 1000) + const bootstrap = [bootstrapAddr] parallel([ - (cb) => node2.api.cat(res[0].hash, cb), - (cb) => node3.api.cat(res[0].hash, cb) - ], (err, res) => { + (cb) => spawnGoDaemon(bootstrap, cb), + (cb) => spawnGoDaemon(bootstrap, cb), + (cb) => spawnGoDaemon(bootstrap, cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - expect(res[0]).to.equalBytes(data) - expect(res[1]).to.equalBytes(data) - done() + spawnedNodes.forEach((node) => nodes.push(node)) + setTimeout(done, 25000) // Wait for peers to have each other on the DHT }) }) + + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) + }) + + it('should get from the network after being added', function (done) { + this.timeout(60 * 1000) + addFileAndCat(nodes[1], [nodes[2], nodes[3]], data, done) + }) }) - }) - describe('a JS bootstrap node in the land of Go', () => { - let bootstrapAddr - let node0 - let node1 - let node2 - let node3 - let data + describe('a Go bootstrap node in the land of JS', () => { + let bootstrapAddr + let nodes = [] + let data = crypto.randomBytes(9001) - // spawn bootstrap daemon and get address - before(function (done) { - this.timeout(60 * 1000) + // spawn bootstrap daemon and get address + before(function (done) { + this.timeout(60 * 1000) + + spawnGoDaemon([], (err, node) => { + expect(err).to.not.exist() + nodes.push(node) + + getBootstrapAddr(nodes[0], (err, res) => { + expect(err).to.not.exist() + bootstrapAddr = res + done() + }) + }) + }) - spawnJsDaemon([], (err, node) => { - expect(err).to.not.exist() - node0 = node + // spawn daemons + before(function (done) { + this.timeout(70 * 1000) + const bootstrap = [bootstrapAddr] - getNodeId(node0, (err, res) => { + parallel([ + (cb) => spawnJsDaemon(bootstrap, cb), + (cb) => spawnJsDaemon(bootstrap, cb), + (cb) => spawnJsDaemon(bootstrap, cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - bootstrapAddr = res - done() + spawnedNodes.forEach((node) => nodes.push(node)) + setTimeout(done, 25000) // Wait for peers to have each other on the DHT }) }) - }) - // spawn daemons - before(function (done) { - this.timeout(70 * 1000) - const bootstrap = [bootstrapAddr] - - parallel([ - (cb) => spawnGoDaemon(bootstrap, cb), - (cb) => spawnGoDaemon(bootstrap, cb), - (cb) => spawnGoDaemon(bootstrap, cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - node3 = nodes[2] - done() + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) }) - }) - // create data - before(function (done) { - data = crypto.randomBytes(9001) - done() + it('should get from the network after being added', function (done) { + this.timeout(100 * 1000) + addFileAndCat(nodes[1], [nodes[2], nodes[3]], data, done) + }) }) - after(function (done) { - this.timeout(70 * 1000) - series([ - (cb) => node1.stop(cb), - (cb) => node2.stop(cb), - (cb) => node3.stop(cb), - (cb) => node0.stop(cb) - ], done) - }) + describe('a JS bootstrap node in an hybrid land', () => { + let bootstrapAddr + let nodes = [] + let data = crypto.randomBytes(9001) - it('should get from the network after being added', function (done) { - this.timeout(60 * 1000) + // spawn bootstrap daemon and get address + before(function (done) { + this.timeout(60 * 1000) - node1.api.add(data, (err, res) => { - expect(err).to.not.exist() + spawnJsDaemon([], (err, node) => { + expect(err).to.not.exist() + nodes.push(node) + + getBootstrapAddr(nodes[0], (err, res) => { + expect(err).to.not.exist() + bootstrapAddr = res + done() + }) + }) + }) + + // spawn daemons + before(function (done) { + this.timeout(70 * 1000) + const bootstrap = [bootstrapAddr] parallel([ - (cb) => node2.api.cat(res[0].hash, cb), - (cb) => node3.api.cat(res[0].hash, cb) - ], (err, res) => { + (cb) => spawnGoDaemon(bootstrap, cb), + (cb) => spawnJsDaemon(bootstrap, cb), + (cb) => spawnGoDaemon(bootstrap, cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - expect(res[0]).to.equalBytes(data) - expect(res[1]).to.equalBytes(data) - done() + spawnedNodes.forEach((node) => nodes.push(node)) + setTimeout(done, 25000) // Wait for peers to have each other on the DHT }) }) + + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) + }) + + it('should get from the network after being added', function (done) { + this.timeout(60 * 1000) + + addFileAndCat(nodes[1], [nodes[2], nodes[3]], data, done) + }) }) - }) - describe('a Go bootstrap node in the land of JS', () => { - let bootstrapAddr - let node0 - let node1 - let node2 - let node3 - let data + describe('a Go bootstrap node in an hybrid land', () => { + let bootstrapAddr + let nodes = [] + let data = crypto.randomBytes(9001) + + // spawn bootstrap daemon and get address + before(function (done) { + this.timeout(60 * 1000) - // spawn bootstrap daemon and get address - before(function (done) { - this.timeout(60 * 1000) + spawnGoDaemon([], (err, node) => { + expect(err).to.not.exist() + nodes.push(node) + + getBootstrapAddr(nodes[0], (err, res) => { + expect(err).to.not.exist() + bootstrapAddr = res + done() + }) + }) + }) - spawnGoDaemon([], (err, node) => { - expect(err).to.not.exist() - node0 = node + // spawn daemons + before(function (done) { + this.timeout(70 * 1000) + const bootstrap = [bootstrapAddr] - getNodeId(node0, (err, res) => { + parallel([ + (cb) => spawnJsDaemon(bootstrap, cb), + (cb) => spawnGoDaemon(bootstrap, cb), + (cb) => spawnJsDaemon(bootstrap, cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - bootstrapAddr = res - done() + spawnedNodes.forEach((node) => nodes.push(node)) + setTimeout(done, 25000) // Wait for peers to have each other on the DHT }) }) - }) - // spawn daemons - before(function (done) { - this.timeout(70 * 1000) - const bootstrap = [bootstrapAddr] - - parallel([ - (cb) => spawnJsDaemon(bootstrap, cb), - (cb) => spawnJsDaemon(bootstrap, cb), - (cb) => spawnJsDaemon(bootstrap, cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - node3 = nodes[2] - done() + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) }) - }) - // create data - before(function (done) { - data = crypto.randomBytes(9001) - done() - }) + it('should get from the network after being added', function (done) { + this.timeout(60 * 1000) - after(function (done) { - this.timeout(70 * 1000) - series([ - (cb) => node1.stop(cb), - (cb) => node2.stop(cb), - (cb) => node3.stop(cb), - (cb) => node0.stop(cb) - ], done) + addFileAndCat(nodes[1], [nodes[2], nodes[3]], data, done) + }) }) + }) - it('should get from the network after being added', function (done) { - this.timeout(100 * 1000) + describe('kad-dht with connections per peer', () => { + describe('a JS node in the land of Go', () => { + let nodes = [] - node1.api.add(data, (err, res) => { - expect(err).to.not.exist() + // Spawn daemons + before(function (done) { + this.timeout(60 * 1000) parallel([ - (cb) => node2.api.cat(res[0].hash, cb), - (cb) => node3.api.cat(res[0].hash, cb) - ], (err, res) => { + (cb) => spawnGoDaemon([], cb), + (cb) => spawnGoDaemon([], cb), + (cb) => spawnGoDaemon([], cb), + (cb) => spawnJsDaemon([], cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - expect(res[0]).to.equalBytes(data) - expect(res[1]).to.equalBytes(data) + nodes = spawnedNodes done() }) }) - }) - }) - - describe('a JS bootstrap node in an hybrid land', () => { - let bootstrapAddr - let node0 - let node1 - let node2 - let node3 - let data - // spawn bootstrap daemon and get address - before(function (done) { - this.timeout(60 * 1000) + // make connections + before(function (done) { + this.timeout(60 * 1000) - spawnJsDaemon([], (err, node) => { - expect(err).to.not.exist() - node0 = node - - getNodeId(node0, (err, res) => { + parallel(nodes.map((node) => (cb) => node.api.id(cb)), (err, ids) => { expect(err).to.not.exist() - bootstrapAddr = res - done() + parallel([ + (cb) => nodes[3].api.swarm.connect(ids[0].addresses[0], cb), + (cb) => nodes[0].api.swarm.connect(ids[1].addresses[0], cb), + (cb) => nodes[1].api.swarm.connect(ids[2].addresses[0], cb) + ], done) }) }) - }) - // spawn daemons - before(function (done) { - this.timeout(70 * 1000) - const bootstrap = [bootstrapAddr] - - parallel([ - (cb) => spawnGoDaemon(bootstrap, cb), - (cb) => spawnJsDaemon(bootstrap, cb), - (cb) => spawnGoDaemon(bootstrap, cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - node3 = nodes[2] - done() + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) }) - }) - // create data - before(function (done) { - data = crypto.randomBytes(9001) - done() - }) + it('one hop', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) - after(function (done) { - this.timeout(70 * 1000) - series([ - (cb) => node1.stop(cb), - (cb) => node2.stop(cb), - (cb) => node3.stop(cb), - (cb) => node0.stop(cb) - ], done) + addFileAndCat(nodes[0], [nodes[3]], data, done) + }) + + it('two hops', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[1], [nodes[3]], data, done) + }) + + it('three hops', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[2], [nodes[3]], data, done) + }) }) - it('should get from the network after being added', function (done) { - this.timeout(60 * 1000) + describe('a Go node in the land of JS', () => { + let nodes = [] - node1.api.add(data, (err, res) => { - expect(err).to.not.exist() + // Spawn daemons + before(function (done) { + this.timeout(60 * 1000) parallel([ - (cb) => node2.api.cat(res[0].hash, cb), - (cb) => node3.api.cat(res[0].hash, cb) - ], (err, res) => { + (cb) => spawnJsDaemon([], cb), + (cb) => spawnJsDaemon([], cb), + (cb) => spawnJsDaemon([], cb), + (cb) => spawnGoDaemon([], cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - expect(res[0]).to.equalBytes(data) - expect(res[1]).to.equalBytes(data) + nodes = spawnedNodes done() }) }) - }) - }) - - describe('a Go bootstrap node in an hybrid land', () => { - let bootstrapAddr - let node0 - let node1 - let node2 - let node3 - let data - // spawn bootstrap daemon and get address - before(function (done) { - this.timeout(60 * 1000) + // make connections + before(function (done) { + this.timeout(60 * 1000) - spawnGoDaemon([], (err, node) => { - expect(err).to.not.exist() - node0 = node - - getNodeId(node0, (err, res) => { + parallel(nodes.map((node) => (cb) => node.api.id(cb)), (err, ids) => { expect(err).to.not.exist() - bootstrapAddr = res - done() + parallel([ + (cb) => nodes[3].api.swarm.connect(ids[0].addresses[0], cb), + (cb) => nodes[0].api.swarm.connect(ids[1].addresses[0], cb), + (cb) => nodes[1].api.swarm.connect(ids[2].addresses[0], cb) + ], done) }) }) - }) - // spawn daemons - before(function (done) { - this.timeout(70 * 1000) - const bootstrap = [bootstrapAddr] - - parallel([ - (cb) => spawnJsDaemon(bootstrap, cb), - (cb) => spawnGoDaemon(bootstrap, cb), - (cb) => spawnJsDaemon(bootstrap, cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - node3 = nodes[2] - done() + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) }) - }) - // create data - before(function (done) { - data = crypto.randomBytes(9001) - done() - }) + it('one hop', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) - after(function (done) { - this.timeout(70 * 1000) - series([ - (cb) => node1.stop(cb), - (cb) => node2.stop(cb), - (cb) => node3.stop(cb), - (cb) => node0.stop(cb) - ], done) + addFileAndCat(nodes[0], [nodes[3]], data, done) + }) + + it('two hops', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[1], [nodes[3]], data, done) + }) + + it('three hops', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[2], [nodes[3]], data, done) + }) }) - it('should get from the network after being added', function (done) { - this.timeout(60 * 1000) + describe('hybrid', () => { + let nodes = [] - node1.api.add(data, (err, res) => { - expect(err).to.not.exist() + // Spawn daemons + before(function (done) { + this.timeout(60 * 1000) parallel([ - (cb) => node2.api.cat(res[0].hash, cb), - (cb) => node3.api.cat(res[0].hash, cb) - ], (err, res) => { + (cb) => spawnJsDaemon([], cb), + (cb) => spawnGoDaemon([], cb), + (cb) => spawnJsDaemon([], cb), + (cb) => spawnGoDaemon([], cb) + ], (err, spawnedNodes) => { expect(err).to.not.exist() - expect(res[0]).to.equalBytes(data) - expect(res[1]).to.equalBytes(data) + nodes = spawnedNodes done() }) }) + + // make connections + before(function (done) { + this.timeout(60 * 1000) + + parallel(nodes.map((node) => (cb) => node.api.id(cb)), (err, ids) => { + expect(err).to.not.exist() + parallel([ + (cb) => nodes[3].api.swarm.connect(ids[0].addresses[0], cb), + (cb) => nodes[0].api.swarm.connect(ids[1].addresses[0], cb), + (cb) => nodes[1].api.swarm.connect(ids[2].addresses[0], cb) + ], done) + }) + }) + + after(function (done) { + this.timeout(80 * 1000) + parallel(nodes.map((node) => (cb) => node.stop(cb)), done) + }) + + it('one hop', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[0], [nodes[3]], data, done) + }) + + it('two hops', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[1], [nodes[3]], data, done) + }) + + it('three hops', function (done) { + this.timeout(85 * 1000) + const data = crypto.randomBytes(9001) + + addFileAndCat(nodes[2], [nodes[3]], data, done) + }) }) }) })