From e96107b8dc30b68f19ef46a015baef901c052e52 Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 5 Jul 2017 09:20:37 +0100 Subject: [PATCH 1/2] wip --- package.json | 1 + test/core/bootstrapers.spec.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/core/bootstrapers.spec.js diff --git a/package.json b/package.json index 3716f0aaf7..c49fb80fba 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "test:interop": "IPFS_TEST=interop aegir test -t node -t browser -f test/interop", "test:interop:node": "IPFS_TEST=interop aegir test -t node -f test/interop/node.js", "test:interop:browser": "IPFS_TEST=interop aegir test -t browser -f test/interop/browser.js", + "test:bootstrapers": "aegir test -t browser -f test/bootstrapers.js", "test:benchmark": "echo \"Error: no benchmarks yet\" && exit 1", "test:benchmark:node": "echo \"Error: no benchmarks yet\" && exit 1", "test:benchmark:node:core": "echo \"Error: no benchmarks yet\" && exit 1", diff --git a/test/core/bootstrapers.spec.js b/test/core/bootstrapers.spec.js new file mode 100644 index 0000000000..966ac67a65 --- /dev/null +++ b/test/core/bootstrapers.spec.js @@ -0,0 +1,33 @@ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) +const IPFS = require('../..') + +/* + * These tests were graciously made for lgierth, so that he can test + * the WebSockets Bootstrappers easily :) + */ +console.log('=>', process.env.TEST_BOOTSTRAPERS) +if (process.env.TEST_BOOTSTRAPERS) { + describe.only('Check if a connection can be done to the Bootstrapers', () => { + it('a node connects to bootstrapers', (done) => { + const node = new IPFS() + node.on('ready', () => { + setTimeout(() => { + node.swarm.peers((err, peers) => { + expect(err).to.not.exist() + expect(peers.length).to.be.above(7) + node.stop(done) + }) + }, 1000) + }) + }) + + it.skip('bootstrapers connections hold for more than 10 secs', (done) => {}) + it.skip('fetch a file added in this node, from bootstrapers', (done) => {}) + }) +} From 2a91ac49790e34161d240d6e70c9f480a9607b43 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 17 Nov 2017 10:13:32 +0000 Subject: [PATCH 2/2] test: fix bootstrapers tests --- .aegir.js | 5 ++-- package.json | 2 +- test/bootstrapers.js | 45 ++++++++++++++++++++++++++++++++++ test/core/bootstrapers.spec.js | 33 ------------------------- 4 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 test/bootstrapers.js delete mode 100644 test/core/bootstrapers.spec.js diff --git a/.aegir.js b/.aegir.js index f1fe0a7b8a..bd4bdbb6f0 100644 --- a/.aegir.js +++ b/.aegir.js @@ -11,7 +11,6 @@ const stop = ads.stopNodes */ function start (done) { const base = '/ip4/127.0.0.1/tcp' - if (!process.env.IPFS_TEST) { parallel([ (cb) => js([`${base}/10007`, `${base}/20007/ws`], true, 31007, 32007, cb), @@ -21,13 +20,15 @@ function start (done) { (cb) => js([`${base}/10014`, `${base}/20014/ws`], true, 31014, 32014, cb), (cb) => js([`${base}/10015`, `${base}/20015/ws`], true, 31015, 32015, cb) ], done) - } else { + } else if (process.env.IPFS_TEST === 'interop') { parallel([ (cb) => go([`${base}/10027`, `${base}/20027/ws`], true, 33027, 44027, cb), (cb) => go([`${base}/10028`, `${base}/20028/ws`], true, 33028, 44028, cb), (cb) => go([`${base}/10031`, `${base}/20031/ws`], true, 33031, 44031, cb), (cb) => go([`${base}/10032`, `${base}/20032/ws`], true, 33032, 44032, cb) ], done) + } else if (process.env.IPFS_TEST === 'bootstrapers') { + done() } } diff --git a/package.json b/package.json index c49fb80fba..afc9b633a9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "test:interop": "IPFS_TEST=interop aegir test -t node -t browser -f test/interop", "test:interop:node": "IPFS_TEST=interop aegir test -t node -f test/interop/node.js", "test:interop:browser": "IPFS_TEST=interop aegir test -t browser -f test/interop/browser.js", - "test:bootstrapers": "aegir test -t browser -f test/bootstrapers.js", + "test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js", "test:benchmark": "echo \"Error: no benchmarks yet\" && exit 1", "test:benchmark:node": "echo \"Error: no benchmarks yet\" && exit 1", "test:benchmark:node:core": "echo \"Error: no benchmarks yet\" && exit 1", diff --git a/test/bootstrapers.js b/test/bootstrapers.js new file mode 100644 index 0000000000..49ef1f5d10 --- /dev/null +++ b/test/bootstrapers.js @@ -0,0 +1,45 @@ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) +const IPFS = require('..') +const list = require('../src/core/runtime/config-browser.json').Bootstrap + +/* + * These tests were graciously made for lgierth, so that he can test the + * WebSockets Bootstrappers easily <3 + */ +describe('Check that a js-ipfs node can indeed contact the bootstrappers', function () { + this.timeout(60 * 1000) + + it('a node connects to bootstrapers', (done) => { + const node = new IPFS({ + config: { + Addresses: { + Swarm: [] + } + } + }) + + node.on('ready', check) + + function check () { + node.swarm.peers((err, peers) => { + expect(err).to.not.exist() + + if (peers.length !== list.length) { + return setTimeout(check, 2000) + } + + const peerList = peers.map((peer) => peer.addr.toString()) + expect(peers.length).to.equal(list.length) + expect(peerList).to.eql(list) + + node.stop(done) + }) + } + }) +}) diff --git a/test/core/bootstrapers.spec.js b/test/core/bootstrapers.spec.js deleted file mode 100644 index 966ac67a65..0000000000 --- a/test/core/bootstrapers.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) -const IPFS = require('../..') - -/* - * These tests were graciously made for lgierth, so that he can test - * the WebSockets Bootstrappers easily :) - */ -console.log('=>', process.env.TEST_BOOTSTRAPERS) -if (process.env.TEST_BOOTSTRAPERS) { - describe.only('Check if a connection can be done to the Bootstrapers', () => { - it('a node connects to bootstrapers', (done) => { - const node = new IPFS() - node.on('ready', () => { - setTimeout(() => { - node.swarm.peers((err, peers) => { - expect(err).to.not.exist() - expect(peers.length).to.be.above(7) - node.stop(done) - }) - }, 1000) - }) - }) - - it.skip('bootstrapers connections hold for more than 10 secs', (done) => {}) - it.skip('fetch a file added in this node, from bootstrapers', (done) => {}) - }) -}