Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
test: bootstrapers tests, for @lgierth (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias authored Nov 17, 2017
1 parent 6db3fb8 commit b2106c1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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()
}
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 45 additions & 0 deletions test/bootstrapers.js
Original file line number Diff line number Diff line change
@@ -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)
})
}
})
})

0 comments on commit b2106c1

Please sign in to comment.