Skip to content

Commit

Permalink
chore: enable some browser tests (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored May 30, 2019
1 parent 0132043 commit b8b2d93
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 112 deletions.
71 changes: 71 additions & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use strict'

const pull = require('pull-stream')
const parallel = require('async/parallel')
const WebSocketStarRendezvous = require('libp2p-websocket-star-rendezvous')

const Node = require('./test/utils/nodejs-bundle.js')
const {
getPeerRelay,
WS_RENDEZVOUS_MULTIADDR
} = require('./test/utils/constants')

let wsRendezvous
let node

const before = (done) => {
parallel([
(cb) => {
WebSocketStarRendezvous.start({
port: WS_RENDEZVOUS_MULTIADDR.nodeAddress().port,
refreshPeerListIntervalMS: 1000,
strictMultiaddr: false,
cryptoChallenge: true
}, (err, _server) => {
if (err) {
return cb(err)
}
wsRendezvous = _server
cb()
})
},
(cb) => {
getPeerRelay((err, peerInfo) => {
if (err) {
return done(err)
}

node = new Node({
peerInfo,
config: {
relay: {
enabled: true,
hop: {
enabled: true,
active: true
}
}
}
})

node.handle('/echo/1.0.0', (_, conn) => pull(conn, conn))
node.start(cb)
})
}
], done)
}

const after = (done) => {
setTimeout(() =>
parallel(
[node, wsRendezvous].map((s) => (cb) => s.stop(cb)),
done),
2000)
}

module.exports = {
hooks: {
pre: before,
post: after
}
}
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,21 @@ jobs:
- npx aegir dep-check -- -i wrtc -i electron-webrtc
- npm run lint

- stage: test
name: chrome
addons:
chrome: stable
script:
- npx aegir test -t browser
- npx aegir test -t webworker

- stage: test
name: firefox
addons:
firefox: latest
script:
- npx aegir test -t browser -- --browsers FirefoxHeadless
- npx aegir test -t webworker -- --browsers FirefoxHeadless

notifications:
email: false
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls"
},
"browser": {
"test/utils/nodejs-bundle": "./test/utils/browser-bundle.js"
},
"files": [
"src",
"dist"
Expand Down Expand Up @@ -46,12 +49,16 @@
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"chai-spies": "^1.0.0",
"detect-node": "^2.0.4",
"dirty-chai": "^2.0.1",
"libp2p": "~0.24.4",
"libp2p-secio": "~0.11.1",
"libp2p-spdy": "~0.13.3",
"libp2p-tcp": "~0.13.0",
"libp2p-websocket-star": "~0.10.2",
"libp2p-websocket-star-rendezvous": "~0.3.0",
"lodash": "^4.17.11",
"multiaddr": "^6.0.6",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",
"sinon": "^7.3.2"
Expand Down
28 changes: 14 additions & 14 deletions test/2-nodes.js → test/2-nodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('basics between 2 nodes', () => {

before((done) => {
series([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (err, nodes) => {
if (err) {
return done(err)
Expand Down Expand Up @@ -209,8 +209,8 @@ describe('basics between 2 nodes', () => {

before((done) => {
parallel([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (err, nodes) => {
expect(err).to.not.exist()

Expand Down Expand Up @@ -285,8 +285,8 @@ describe('basics between 2 nodes', () => {

before((done) => {
series([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (cb, nodes) => {
nodeA = nodes[0]
nodeB = nodes[1]
Expand Down Expand Up @@ -352,8 +352,8 @@ describe('basics between 2 nodes', () => {

before((done) => {
series([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (cb, nodes) => {
nodeA = nodes[0]
nodeB = nodes[1]
Expand Down Expand Up @@ -403,8 +403,8 @@ describe('basics between 2 nodes', () => {
sandbox = chai.spy.sandbox()

series([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (err, nodes) => {
if (err) return done(err)

Expand Down Expand Up @@ -464,8 +464,8 @@ describe('basics between 2 nodes', () => {
sandbox = chai.spy.sandbox()

series([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (err, nodes) => {
if (err) return done(err)

Expand Down Expand Up @@ -536,8 +536,8 @@ describe('basics between 2 nodes', () => {
sandbox = chai.spy.sandbox()

series([
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb),
(cb) => createNode('/ip4/127.0.0.1/tcp/0', cb)
(cb) => createNode(cb),
(cb) => createNode(cb)
], (err, nodes) => {
if (err) return done(err)

Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/test-peer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "Qmex1SSsueWFsUfjdkugJ5zhcnjddAt8TxcnDLUXKD9Sx7",
"privKey": "CAASqAkwggSkAgEAAoIBAQCXzV127CvVHOGMzvsn/U+/32JM58KA6k0FSCCeNFzNowiDS/vV5eezGN5AFoxsF6icWLoaczz7l9RdVD+I/t6PEt9X7XUdrDCtSS8WmAcCgvZWSSf7yAd3jT4GSZDUIgIEeRZsERDt/yVqTLwsZ1G9dMIeh8sbf2zwjTXZIWaRM6o4lq3DYFfzLvJUXlJodxPogU7l7nLkITPUv+yQAMcVHizbNwJvwiETKYeUj73/m/wEPAlnFESexDstxNiIw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