From 6022b469d18a555b05f58d11d77cf036edcd3beb Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 10 May 2016 14:29:38 +0200 Subject: [PATCH] feat: integrate libp2p-ipfs-browser --- gulpfile.js | 39 ++++++++ package.json | 27 +++--- src/core/ipfs/id.js | 2 +- src/core/ipfs/libp2p.js | 3 +- test/cli-tests/test-bitswap.js | 2 +- test/cli-tests/test-id.js | 39 ++++---- test/cli-tests/test-swarm.js | 2 +- test/core-tests/test-bitswap.js | 144 ++++++++++++++--------------- test/core-tests/test-config.js | 2 +- test/core-tests/test-id.js | 8 +- test/core-tests/test-swarm-node.js | 12 +-- test/go-ipfs-repo/config | 2 +- test/http-api-tests/test-swarm.js | 2 +- test/utils/temp-node.js | 3 +- 14 files changed, 160 insertions(+), 127 deletions(-) create mode 100644 gulpfile.js diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..597141b6d4 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,39 @@ +'use strict' + +const gulp = require('gulp') +const async = require('async') +const createTempNode = require('./test/utils/temp-node') +const API = require('./src/http-api') + +const nodes = [] + +function startNode (num, done) { + createTempNode(num, (err, node) => { + if (err) throw err + + const api = new API(node.repo.path()) + nodes.push(api) + api.start(done) + }) +} + +gulp.task('libnode:start', (done) => { + async.parallel([ + (cb) => startNode(7, cb), + (cb) => startNode(8, cb), + (cb) => startNode(9, cb) + ], done) +}) + +gulp.task('libnode:stop', (done) => { + async.eachSeries(nodes, (node, cb) => { + setTimeout(() => node.stop(cb), 500) + }, done) +}) + +gulp.task('test:browser:before', ['libnode:start']) +gulp.task('test:node:before', ['libnode:start']) +gulp.task('test:browser:after', ['libnode:stop']) +gulp.task('test:node:after', ['libnode:stop']) + +require('aegir/gulp')(gulp) diff --git a/package.json b/package.json index 64ff438175..d711f79b3e 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,14 @@ "jsnext:main": "src/core/index.js", "scripts": { "lint": "aegir-lint", - "coverage": "aegir-coverage", - "test": "aegir-test", - "test:node": "aegir-test node", - "test:browser": "aegir-test browser", - "build": "aegir-build", - "release": "aegir-release", - "release:minor": "aegir-release --type minor", - "release:major": "aegir-release --type major", + "coverage": "gulp coverage", + "test": "gulp test", + "test:node": "gulp test:node", + "test:browser": "gulp test:browser", + "build": "gulp build", + "release": "gulp release", + "release:minor": "gulp release --type minor", + "release:major": "gulp release --type major", "coverage-publish": "aegir-coverage publish" }, "pre-commit": [ @@ -43,7 +43,9 @@ "chai": "^3.5.0", "expose-loader": "^0.7.1", "form-data": "^1.0.0-rc3", + "gulp": "^3.9.1", "idb-plus-blob-store": "^1.1.2", + "libp2p-ipfs-browser": "^0.2.0", "lodash": "^4.11.2", "mocha": "^2.4.5", "ncp": "^2.0.0", @@ -72,12 +74,12 @@ "ipfs-unixfs-engine": "^0.6.1", "joi": "^8.0.5", "libp2p-ipfs": "^0.3.3", - "libp2p-swarm": "^0.12.5", + "libp2p-swarm": "^0.12.11", "lodash.get": "^4.2.1", "lodash.set": "^4.1.0", "multiaddr": "^1.4.1", "path-exists": "^3.0.0", - "peer-book": "0.1.0", + "peer-book": "^0.1.1", "peer-id": "^0.6.6", "peer-info": "^0.6.2", "readable-stream": "1.1.13", @@ -88,13 +90,12 @@ "webpack": { "resolve": { "alias": { - "node-forge": "../../../node_modules/peer-id/vendor/forge.bundle.js" + "node-forge": "../../../node_modules/peer-id/vendor/forge.bundle.js", + "libp2p-ipfs": "libp2p-ipfs-browser" } }, "externals": { "fs": "{}", - "ipfs-data-importing": "{ import: {} }", - "libp2p-ipfs": "{}", "mkdirp": "{}" } } diff --git a/src/core/ipfs/id.js b/src/core/ipfs/id.js index 835fc79327..d322b02d51 100644 --- a/src/core/ipfs/id.js +++ b/src/core/ipfs/id.js @@ -16,7 +16,7 @@ module.exports = function id (self) { callback(null, { ID: self._peerInfo.id.toB58String(), PublicKey: self._peerInfo.id.pubKey.toString('base64'), - Addresses: self._peerInfo.multiaddrs.map((ma) => { return ma.toString() }), + Addresses: self._peerInfo.multiaddrs.map((ma) => { return ma.toString() }).sort(), AgentVersion: 'js-ipfs', ProtocolVersion: '9000' }) diff --git a/src/core/ipfs/libp2p.js b/src/core/ipfs/libp2p.js index 570a403e7d..9a7569015f 100644 --- a/src/core/ipfs/libp2p.js +++ b/src/core/ipfs/libp2p.js @@ -57,9 +57,8 @@ module.exports = function libp2p (self) { const id = peerId.createFromB58String(idStr[1]) const peer = new PeerInfo(id) - ma = ma.toString().replace(/\/ipfs\/(.*)/, '') // FIXME remove this when multiaddr supports ipfs - peer.multiaddr.add(multiaddr(ma)) + self._peerInfoBook.put(peer) self._libp2pNode.swarm.dial(peer, (err) => { diff --git a/test/cli-tests/test-bitswap.js b/test/cli-tests/test-bitswap.js index 9021cd8e64..baec2e6356 100644 --- a/test/cli-tests/test-bitswap.js +++ b/test/cli-tests/test-bitswap.js @@ -19,7 +19,7 @@ describe('bitswap', function () { let ipfs before((done) => { - createTempNode(8, (err, _ipfs) => { + createTempNode(4, (err, _ipfs) => { expect(err).to.not.exist ipfs = _ipfs ipfs.goOnline(done) diff --git a/test/cli-tests/test-id.js b/test/cli-tests/test-id.js index 2511dae654..6e092e8bff 100644 --- a/test/cli-tests/test-id.js +++ b/test/cli-tests/test-id.js @@ -15,20 +15,18 @@ describe('id', () => { it('get the id', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'id'], {env}) .run((err, stdout, exitcode) => { - var expected = [ "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',", + expect( + stdout + ).to.be.eql([ + "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',", " PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',", - " Addresses: [ '/ip4/0.0.0.0/tcp/0'],", + ' Addresses: ', + " [ '/ip4/127.0.0.1/tcp/9990/websockets',", + " '/ip4/127.0.0.1/tcp/9999' ],", " AgentVersion: 'js-ipfs',", - " ProtocolVersion: '9000' }" ] + " ProtocolVersion: '9000' }" + ]) - expect(stdout[0]).to.equal(expected[0]) - expect(stdout[1]).to.equal(expected[1]) - // expect(stdout[2]).to.equal(expected[2]) - expect(stdout[3]).to.equal(expected[3]) - expect(stdout[4]).to.equal(expected[4]) - expect(stdout[5]).to.equal(expected[5]) - expect(stdout[6]).to.equal(expected[6]) - expect(stdout[7]).to.equal(expected[7]) expect(err).to.not.exist expect(exitcode).to.equal(0) done() @@ -57,21 +55,18 @@ describe('id', () => { it('get the id', (done) => { nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'id'], {env}) .run((err, stdout, exitcode) => { - var expected = [ + expect( + stdout + ).to.be.eql([ "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',", " PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',", - " Addresses: [ '/ip4/0.0.0.0/tcp/0' ],", + ' Addresses: ', + " [ '/ip4/127.0.0.1/tcp/9990/websockets',", + " '/ip4/127.0.0.1/tcp/9999' ],", " AgentVersion: 'js-ipfs',", - " ProtocolVersion: '9000' }" ] + " ProtocolVersion: '9000' }" + ]) - expect(stdout[0]).to.equal(expected[0]) - expect(stdout[1]).to.equal(expected[1]) - // expect(stdout[2]).to.equal(expected[2]) - expect(stdout[3]).to.equal(expected[3]) - expect(stdout[4]).to.equal(expected[4]) - expect(stdout[5]).to.equal(expected[5]) - expect(stdout[6]).to.equal(expected[6]) - expect(stdout[7]).to.equal(expected[7]) expect(err).to.not.exist expect(exitcode).to.equal(0) done() diff --git a/test/cli-tests/test-swarm.js b/test/cli-tests/test-swarm.js index 1bc3e8b303..ab412992be 100644 --- a/test/cli-tests/test-swarm.js +++ b/test/cli-tests/test-swarm.js @@ -17,7 +17,7 @@ describe('swarm', function () { var ipfsAddr before((done) => { - createTempNode(9, (err, _ipfs) => { + createTempNode(2, (err, _ipfs) => { expect(err).to.not.exist ipfs = _ipfs ipfs.goOnline((err) => { diff --git a/test/core-tests/test-bitswap.js b/test/core-tests/test-bitswap.js index 9ef02299aa..77f4518d2e 100644 --- a/test/core-tests/test-bitswap.js +++ b/test/core-tests/test-bitswap.js @@ -5,12 +5,16 @@ const expect = require('chai').expect const _ = require('lodash') const async = require('async') const Block = require('ipfs-block') -const Readable = require('stream').Readable const bs58 = require('bs58') const bl = require('bl') +const API = require('ipfs-api') +const multiaddr = require('multiaddr') const IPFS = require('../../src/core') -const createTempNode = require('../utils/temp-node') + +function makeBlock () { + return new Block(`IPFS is awesome ${Math.random()}`) +} describe('bitswap', () => { let ipfs @@ -21,41 +25,40 @@ describe('bitswap', () => { }) describe('connections', () => { - function getAndAssertBlock (node, key, block, cb) { - node.block.get(key, (err, b) => { - expect(err).to.not.exist - expect(b.data.toString()).to.be.eql(block.data.toString()) - cb() - }) - } - function connectNodesSingle (node1, node2, done) { node1.id((err, res) => { expect(err).to.not.exist - node2.libp2p.swarm.connect(`${res.Addresses[0]}/ipfs/${res.ID}`, done) + const addr = res.Addresses + .map((addr) => multiaddr(addr)) + .filter((addr) => { + return _.includes(addr.protoNames(), 'websockets') + })[0] + + let target = addr.encapsulate(multiaddr(`/ipfs/${res.ID}`)).toString() + + target = target.replace('0.0.0.0', '127.0.0.1') + const swarm = node2.libp2p ? node2.libp2p.swarm : node2.swarm + console.log('connecting to %s', target) + swarm.connect(target, done) }) } function connectNodes (node1, node2, done) { - async.parallel([ + async.series([ (cb) => connectNodesSingle(node1, node2, cb), - (cb) => connectNodesSingle(node2, node1, cb) + (cb) => setTimeout(() => { + // need timeout so we wait for identify to happen + // in the browsers + connectNodesSingle(node2, node1, cb) + }, 500) ], done) } function addNode (num, done) { - let node - async.waterfall([ - (cb) => { - createTempNode(num, (err, _ipfs) => { - expect(err).to.not.exist - node = _ipfs - cb() - }) - }, - (cb) => node.goOnline(cb), - (cb) => connectNodes(node, ipfs, cb) - ], (err) => { + const apiUrl = `/ip4/127.0.0.1/tcp/1100${num}` + const node = new API(apiUrl) + + connectNodes(node, ipfs, (err) => { done(err, node) }) } @@ -65,105 +68,95 @@ describe('bitswap', () => { ipfs.goOnline(done) }) + afterEach((done) => { + setTimeout(() => ipfs.goOffline(done), 500) + }) + it('2 peers', (done) => { - const block = new Block('I am awesome, 2') + const block = makeBlock() let node async.series([ // 0. Start node - (cb) => addNode(6, (err, _ipfs) => { + (cb) => addNode(9, (err, _ipfs) => { node = _ipfs cb(err) }), - // 1. Add file to tmp instance - (cb) => node.block.put(block, cb), - // 2. Request file from local instance + (cb) => node.block.put(block.data, cb), (cb) => { ipfs.block.get(block.key, (err, b) => { expect(err).to.not.exist - // 3. Profit - expect(b.data.toString()).to.be.eql('I am awesome, 2') + expect(b.data.toString()).to.be.eql(block.data.toString()) cb() }) - }, - (cb) => setTimeout(() => node.goOffline(cb), 1000) + } ], done) }) it('3 peers', function (done) { this.timeout(60 * 1000) - const blocks = _.range(6).map((i) => new Block(`I am awesome, ${i}`)) + const blocks = _.range(6).map((i) => makeBlock()) const keys = blocks.map((b) => b.key) const nodes = [] async.series([ - // 0. Start node 1 - (cb) => addNode(6, (err, _ipfs) => { + (cb) => addNode(8, (err, _ipfs) => { nodes.push(_ipfs) cb(err) }), - // 1. Start node 2 (cb) => addNode(7, (err, _ipfs) => { nodes.push(_ipfs) cb(err) }), (cb) => connectNodes(nodes[0], nodes[1], cb), - // 2. Put blocks on all nodes - (cb) => nodes[0].block.put(blocks[0], cb), - (cb) => nodes[0].block.put(blocks[1], cb), - (cb) => nodes[1].block.put(blocks[2], cb), - (cb) => nodes[1].block.put(blocks[3], cb), + (cb) => nodes[0].block.put(blocks[0].data, cb), + (cb) => nodes[0].block.put(blocks[1].data, cb), + (cb) => nodes[1].block.put(blocks[2].data, cb), + (cb) => nodes[1].block.put(blocks[3].data, cb), (cb) => ipfs.block.put(blocks[4], cb), (cb) => ipfs.block.put(blocks[5], cb), // 3. Fetch blocks on all nodes - (cb) => async.parallel([ - (cb) => { - async.each(_.range(6), (i, innerCb) => { - getAndAssertBlock(nodes[0], keys[i], blocks[i], innerCb) - }, cb) - }, - (cb) => { - async.each(_.range(6), (i, innerCb) => { - getAndAssertBlock(nodes[1], keys[i], blocks[i], innerCb) - }, cb) - }, - (cb) => { - async.each(_.range(6), (i, innerCb) => { - getAndAssertBlock(ipfs, keys[i], blocks[i], innerCb) - }, cb) + (cb) => async.each(_.range(6), (i, cbI) => { + const toMh = (k) => bs58.encode(k).toString() + const check = (n, k, callback) => { + n.block.get(k, (err, b) => { + expect(err).to.not.exist + expect( + (b.data || b).toString() + ).to.be.eql( + blocks[i].data.toString() + ) + callback() + }) } - ], cb), - // 4. go offline - (cb) => setTimeout(() => { - // need to wait a bit to let the sockets finish handshakes - async.parallel([ - (cb) => nodes[0].goOffline(cb), - (cb) => nodes[1].goOffline(cb) - ], cb) - }, 1000) + + async.series([ + (cbJ) => check(nodes[0], toMh(keys[i]), cbJ), + (cbJ) => check(nodes[1], toMh(keys[i]), cbJ), + (cbJ) => check(ipfs, keys[i], cbJ) + ], cbI) + }, cb) ], done) }) }) - describe('fetches a remote file', () => { + // wont work without http-api for add + describe.skip('fetches a remote file', () => { beforeEach((done) => { ipfs.goOnline(done) }) it('2 peers', (done) => { const file = new Buffer('I love IPFS <3') - const rs = new Readable() - rs.push(file) - rs.push(null) let node async.waterfall([ // 0. Start node - (cb) => addNode(6, (err, _ipfs) => { + (cb) => addNode(9, (err, _ipfs) => { node = _ipfs cb(err) }), // 1. Add file to tmp instance - (cb) => node.files.add([{path: 'awesome.txt', stream: rs}], cb), + (cb) => node.add([{path: 'awesome.txt', content: file}], cb), // 2. Request file from local instance (val, cb) => { const hash = bs58.encode(val[0].multihash).toString() @@ -203,7 +196,7 @@ describe('bitswap', () => { [] ) - done() + ipfs.goOffline(done) }) }) @@ -227,7 +220,8 @@ describe('bitswap', () => { 'dupDataReceived', 'dupBlksReceived' ]) - done() + + ipfs.goOffline(done) }) }) }) diff --git a/test/core-tests/test-config.js b/test/core-tests/test-config.js index c870c4969f..22157c726b 100644 --- a/test/core-tests/test-config.js +++ b/test/core-tests/test-config.js @@ -16,7 +16,7 @@ describe('config', () => { GCPeriod: '', Params: null, NoSync: false }, - Addresses: { Swarm: [ '/ip4/0.0.0.0/tcp/0' ], + Addresses: { Swarm: [ '/ip4/127.0.0.1/tcp/9999', '/ip4/127.0.0.1/tcp/9990/websockets' ], API: '/ip4/127.0.0.1/tcp/6001', Gateway: '/ip4/127.0.0.1/tcp/0' }, Mounts: { IPFS: '/ipfs', IPNS: '/ipns', FuseAllowOther: false }, diff --git a/test/core-tests/test-id.js b/test/core-tests/test-id.js index fc6e4f397b..3ab5837268 100644 --- a/test/core-tests/test-id.js +++ b/test/core-tests/test-id.js @@ -16,9 +16,13 @@ describe('id', () => { it('get id', (done) => { ipfs.id((err, id) => { expect(err).to.not.exist - expect(id).to.deep.equal({ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A', + expect(id).to.deep.equal({ + ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A', PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=', - Addresses: [ '/ip4/0.0.0.0/tcp/0' ], + Addresses: [ + '/ip4/127.0.0.1/tcp/9990/websockets', + '/ip4/127.0.0.1/tcp/9999' + ], AgentVersion: 'js-ipfs', ProtocolVersion: '9000' }) diff --git a/test/core-tests/test-swarm-node.js b/test/core-tests/test-swarm-node.js index c7802e5d6d..502f3e266b 100644 --- a/test/core-tests/test-swarm-node.js +++ b/test/core-tests/test-swarm-node.js @@ -13,11 +13,11 @@ describe('swarm', function () { var ipfsAAddr before((done) => { - createTempNode(3, (err, ipfs) => { + createTempNode(2, (err, ipfs) => { expect(err).to.not.exist ipfsA = ipfs - createTempNode(4, (err, ipfs) => { + createTempNode(3, (err, ipfs) => { expect(err).to.not.exist ipfsB = ipfs done() @@ -61,17 +61,17 @@ describe('swarm', function () { it('localAddrs', (done) => { ipfsB.libp2p.swarm.localAddrs((err, res) => { expect(err).to.not.exist - expect(res.length).to.equal(1) + expect(res.length).to.equal(2) done() }) }) it.skip('disconnect', (done) => {}) - it.skip('stop', (done) => { - ipfsA.libp2p.stop((err) => { + it('stop', (done) => { + ipfsA.goOffline((err) => { expect(err).to.not.exist - done() + ipfsB.goOffline(done) }) }) }) diff --git a/test/go-ipfs-repo/config b/test/go-ipfs-repo/config index 3abd82e380..69bec61203 100644 --- a/test/go-ipfs-repo/config +++ b/test/go-ipfs-repo/config @@ -1 +1 @@ -{"Identity":{"PeerID":"QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A","PrivKey":"CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+ppPER9bdLFxs1t5CrKc078h+wuUr05S1P1JjXk68pk3+kQKBgQDeK8AR11373Mzib6uzpjGzgNRMzdYNuExWjxyxAzz53NAR7zrPHvXvfIqjDScLJ4NcRO2TddhXAfZoOPVH5k4PJHKLBPKuXZpWlookCAyENY7+Pd55S8r+a+MusrMagYNljb5WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+jBKPuoSyYLt1wwe10/lpgL4rkKWU3/m1Myt0tveJ9WcqHh6tzcAbb/fXpUFT/o4SWDimWkPkuCb+8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw=="},"Datastore":{"Type":"","Path":"","StorageMax":"","StorageGCWatermark":0,"GCPeriod":"","Params":null,"NoSync":false},"Addresses":{"Swarm":["/ip4/0.0.0.0/tcp/0"],"API":"/ip4/127.0.0.1/tcp/6001","Gateway":"/ip4/127.0.0.1/tcp/0"},"Mounts":{"IPFS":"/ipfs","IPNS":"/ipns","FuseAllowOther":false},"Version":{"Current":"0.4.0-dev","Check":"error","CheckDate":"0001-01-01T00:00:00Z","CheckPeriod":"172800000000000","AutoUpdate":"minor"},"Discovery":{"MDNS":{"Enabled":true,"Interval":10}},"Ipns":{"RepublishPeriod":"","RecordLifetime":"","ResolveCacheSize":128},"Bootstrap":["/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ","/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z","/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"],"Tour":{"Last":""},"Gateway":{"HTTPHeaders":null,"RootRedirect":"","Writable":false},"SupernodeRouting":{"Servers":["/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U","/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6","/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH","/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP","/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R","/ip4/104.236.76.40/tcp/4002/ipfs/QmdRBCV8Cz2dGhoKLkD3YjPwVFECmqADQkx5ZteF2c6Fy4","/ip4/178.62.158.247/tcp/4002/ipfs/QmUdiMPci7YoEUBkyFZAh2pAbjqcPr7LezyiPD2artLw3v","/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN"]},"API":{"HTTPHeaders":null},"Swarm":{"AddrFilters":null},"Log":{"MaxSizeMB":250,"MaxBackups":1,"MaxAgeDays":0}} +{"Identity":{"PeerID":"QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A","PrivKey":"CAASpgkwggSiAgEAAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAECggEAZtju/bcKvKFPz0mkHiaJcpycy9STKphorpCT83srBVQi59CdFU6Mj+aL/xt0kCPMVigJw8P3/YCEJ9J+rS8BsoWE+xWUEsJvtXoT7vzPHaAtM3ci1HZd302Mz1+GgS8Epdx+7F5p80XAFLDUnELzOzKftvWGZmWfSeDnslwVONkL/1VAzwKy7Ce6hk4SxRE7l2NE2OklSHOzCGU1f78ZzVYKSnS5Ag9YrGjOAmTOXDbKNKN/qIorAQ1bovzGoCwx3iGIatQKFOxyVCyO1PsJYT7JO+kZbhBWRRE+L7l+ppPER9bdLFxs1t5CrKc078h+wuUr05S1P1JjXk68pk3+kQKBgQDeK8AR11373Mzib6uzpjGzgNRMzdYNuExWjxyxAzz53NAR7zrPHvXvfIqjDScLJ4NcRO2TddhXAfZoOPVH5k4PJHKLBPKuXZpWlookCAyENY7+Pd55S8r+a+MusrMagYNljb5WbVTgN8cgdpim9lbbIFlpN6SZaVjLQL3J8TWH6wKBgQDSChzItkqWX11CNstJ9zJyUE20I7LrpyBJNgG1gtvz3ZMUQCn3PxxHtQzN9n1P0mSSYs+jBKPuoSyYLt1wwe10/lpgL4rkKWU3/m1Myt0tveJ9WcqHh6tzcAbb/fXpUFT/o4SWDimWkPkuCb+8j//2yiXk0a/T2f36zKMuZvujqQKBgC6B7BAQDG2H2B/ijofp12ejJU36nL98gAZyqOfpLJ+FeMz4TlBDQ+phIMhnHXA5UkdDapQ+zA3SrFk+6yGk9Vw4Hf46B+82SvOrSbmnMa+PYqKYIvUzR4gg34rL/7AhwnbEyD5hXq4dHwMNsIDq+l2elPjwm/U9V0gdAl2+r50HAoGALtsKqMvhv8HucAMBPrLikhXP/8um8mMKFMrzfqZ+otxfHzlhI0L08Bo3jQrb0Z7ByNY6M8epOmbCKADsbWcVre/AAY0ZkuSZK/CaOXNX/AhMKmKJh8qAOPRY02LIJRBCpfS4czEdnfUhYV/TYiFNnKRj57PPYZdTzUsxa/yVTmECgYBr7slQEjb5Onn5mZnGDh+72BxLNdgwBkhO0OCdpdISqk0F0Pxby22DFOKXZEpiyI9XYP1C8wPiJsShGm2yEwBPWXnrrZNWczaVuCbXHrZkWQogBDG3HGXNdU4MAWCyiYlyinIBpPpoAJZSzpGLmWbMWh28+RJS6AQX6KHrK1o2uw=="},"Datastore":{"Type":"","Path":"","StorageMax":"","StorageGCWatermark":0,"GCPeriod":"","Params":null,"NoSync":false},"Addresses":{"Swarm":["/ip4/127.0.0.1/tcp/9999", "/ip4/127.0.0.1/tcp/9990/websockets"],"API":"/ip4/127.0.0.1/tcp/6001","Gateway":"/ip4/127.0.0.1/tcp/0"},"Mounts":{"IPFS":"/ipfs","IPNS":"/ipns","FuseAllowOther":false},"Version":{"Current":"0.4.0-dev","Check":"error","CheckDate":"0001-01-01T00:00:00Z","CheckPeriod":"172800000000000","AutoUpdate":"minor"},"Discovery":{"MDNS":{"Enabled":true,"Interval":10}},"Ipns":{"RepublishPeriod":"","RecordLifetime":"","ResolveCacheSize":128},"Bootstrap":["/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ","/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z","/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx"],"Tour":{"Last":""},"Gateway":{"HTTPHeaders":null,"RootRedirect":"","Writable":false},"SupernodeRouting":{"Servers":["/ip4/104.236.176.52/tcp/4002/ipfs/QmXdb7tWTxdFEQEFgWBqkuYSrZd3mXrC7HxkD4krGNYx2U","/ip4/104.236.179.241/tcp/4002/ipfs/QmVRqViDByUxjUMoPnjurjKvZhaEMFDtK35FJXHAM4Lkj6","/ip4/104.236.151.122/tcp/4002/ipfs/QmSZwGx8Tn8tmcM4PtDJaMeUQNRhNFdBLVGPzRiNaRJtFH","/ip4/162.243.248.213/tcp/4002/ipfs/QmbHVEEepCi7rn7VL7Exxpd2Ci9NNB6ifvqwhsrbRMgQFP","/ip4/128.199.219.111/tcp/4002/ipfs/Qmb3brdCYmKG1ycwqCbo6LUwWxTuo3FisnJV2yir7oN92R","/ip4/104.236.76.40/tcp/4002/ipfs/QmdRBCV8Cz2dGhoKLkD3YjPwVFECmqADQkx5ZteF2c6Fy4","/ip4/178.62.158.247/tcp/4002/ipfs/QmUdiMPci7YoEUBkyFZAh2pAbjqcPr7LezyiPD2artLw3v","/ip4/178.62.61.185/tcp/4002/ipfs/QmVw6fGNqBixZE4bewRLT2VXX7fAHUHs8JyidDiJ1P7RUN"]},"API":{"HTTPHeaders":null},"Swarm":{"AddrFilters":null},"Log":{"MaxSizeMB":250,"MaxBackups":1,"MaxAgeDays":0}} diff --git a/test/http-api-tests/test-swarm.js b/test/http-api-tests/test-swarm.js index b22d78b7c1..d3d3cd281f 100644 --- a/test/http-api-tests/test-swarm.js +++ b/test/http-api-tests/test-swarm.js @@ -101,7 +101,7 @@ module.exports = (httpAPI) => { var ipfsAddr before((done) => { - createTempNode(7, (err, _ipfs) => { + createTempNode(5, (err, _ipfs) => { expect(err).to.not.exist ipfs = _ipfs ipfs.goOnline(() => { diff --git a/test/utils/temp-node.js b/test/utils/temp-node.js index 3ba5692e6c..444b750ad5 100644 --- a/test/utils/temp-node.js +++ b/test/utils/temp-node.js @@ -11,7 +11,8 @@ function setAddresses (repo, num, callback) { expect(err).to.not.exist config.Addresses = { Swarm: [ - `/ip4/127.0.0.1/tcp/1000${num}` + `/ip4/127.0.0.1/tcp/1000${num}`, + `/ip4/127.0.0.1/tcp/1001${num}/websockets` ], API: `/ip4/127.0.0.1/tcp/1100${num}`, Gateway: `/ip4/127.0.0.1/tcp/1200${num}`