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 3716f0aaf7..afc9b633a9 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": "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) + }) + } + }) +})