Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Isan-Rivkin committed Feb 20, 2019
2 parents 4d42b93 + ec7d076 commit 1879101
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 98 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ test/test-data/go-ipfs-repo/LOG.old

# while testing npm5
package-lock.json
yarn.lock
42 changes: 42 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
language: node_js
cache: npm
stages:
- check
- test
- cov

node_js:
- '10'

os:
- linux
- osx
script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- npx aegir commitlint --travis
- 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
2 changes: 0 additions & 2 deletions ci/Jenkinsfile

This file was deleted.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"test:browser": "aegir test -t browser",
"release": "aegir release -t node -t browser",
"release-minor": "aegir release --type minor -t node -t browser",
"release-major": "aegir release --type major -t node -t browser",
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls"
"release-major": "aegir release --type major -t node -t browser"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -61,7 +59,7 @@
},
"devDependencies": {
"@nodeutils/defaults-deep": "^1.1.0",
"aegir": "^18.0.2",
"aegir": "^18.1.0",
"chai": "^4.2.0",
"chai-checkmark": "^1.0.1",
"cids": "~0.5.5",
Expand All @@ -84,10 +82,10 @@
"lodash.times": "^4.3.2",
"nock": "^10.0.2",
"pull-goodbye": "0.0.2",
"pull-mplex": "~0.1.0",
"pull-serializer": "~0.3.2",
"pull-stream": "^3.6.9",
"sinon": "^7.1.1",
"webrtcsupport": "^2.2.0",
"wrtc": "~0.3.2"
},
"contributors": [
Expand Down
115 changes: 114 additions & 1 deletion test/stream-muxing.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ chai.use(require('dirty-chai'))
const expect = chai.expect
const parallel = require('async/parallel')
const series = require('async/series')
const pMplex = require('pull-mplex')
const Mplex = require('libp2p-mplex')
const SPDY = require('libp2p-spdy')
const createNode = require('./utils/create-node')
Expand Down Expand Up @@ -99,6 +100,42 @@ describe('stream muxing', () => {
], done)
})

it('pMplex only', (done) => {
let nodeA
let nodeB

function setup (callback) {
parallel([
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
modules: {
streamMuxer: [ pMplex ]
}
}, (err, node) => {
expect(err).to.not.exist()
nodeA = node
node.handle('/echo/1.0.0', echo)
node.start(cb)
}),
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
modules: {
streamMuxer: [ pMplex ]
}
}, (err, node) => {
expect(err).to.not.exist()
nodeB = node
node.handle('/echo/1.0.0', echo)
node.start(cb)
})
], callback)
}

series([
(cb) => setup(cb),
(cb) => test(nodeA, nodeB, cb),
(cb) => teardown(nodeA, nodeB, cb)
], done)
})

it('spdy + mplex', function (done) {
this.timeout(5000)

Expand Down Expand Up @@ -137,7 +174,45 @@ describe('stream muxing', () => {
], done)
})

it('spdy + mplex switched order', function (done) {
it('mplex + pull-mplex', function (done) {
this.timeout(5000)

let nodeA
let nodeB

function setup (callback) {
parallel([
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
modules: {
streamMuxer: [ Mplex ]
}
}, (err, node) => {
expect(err).to.not.exist()
nodeA = node
node.handle('/echo/1.0.0', echo)
node.start(cb)
}),
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
modules: {
streamMuxer: [ pMplex ]
}
}, (err, node) => {
expect(err).to.not.exist()
nodeB = node
node.handle('/echo/1.0.0', echo)
node.start(cb)
})
], callback)
}

series([
(cb) => setup(cb),
(cb) => test(nodeA, nodeB, cb),
(cb) => teardown(nodeA, nodeB, cb)
], done)
})

it('spdy + mplex in reverse muxer order', function (done) {
this.timeout(5 * 1000)

let nodeA
Expand Down Expand Up @@ -175,6 +250,44 @@ describe('stream muxing', () => {
], done)
})

it('spdy + pull-mplex in reverse muxer order', function (done) {
this.timeout(5 * 1000)

let nodeA
let nodeB

function setup (callback) {
parallel([
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
modules: {
streamMuxer: [ SPDY, pMplex ]
}
}, (err, node) => {
expect(err).to.not.exist()
nodeA = node
node.handle('/echo/1.0.0', echo)
node.start(cb)
}),
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
modules: {
streamMuxer: [ pMplex, SPDY ]
}
}, (err, node) => {
expect(err).to.not.exist()
nodeB = node
node.handle('/echo/1.0.0', echo)
node.start(cb)
})
], callback)
}

series([
(cb) => setup(cb),
(cb) => test(nodeA, nodeB, cb),
(cb) => teardown(nodeA, nodeB, cb)
], done)
})

it('one without the other fails to establish a muxedConn', function (done) {
this.timeout(5 * 1000)

Expand Down
8 changes: 4 additions & 4 deletions test/transports.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ chai.use(require('dirty-chai'))
const expect = chai.expect
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
const Mplex = require('libp2p-mplex')
const Mplex = require('pull-mplex')
const pull = require('pull-stream')
const parallel = require('async/parallel')
const goodbye = require('pull-goodbye')
const serializer = require('pull-serializer')
const w = require('webrtcsupport')
const wrtcSupport = self.RTCPeerConnection && ('createDataChannel' in self.RTCPeerConnection.prototype)
const tryEcho = require('./utils/try-echo')

const Node = require('./utils/bundle-browser')
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('transports', () => {
streamMuxer: [ Mplex ]
}
})
expect(b._modules.streamMuxer).to.eql([require('libp2p-mplex')])
expect(b._modules.streamMuxer).to.eql([require('pull-mplex')])
done()
})
})
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('transports', () => {

describe('webrtc-star', () => {
/* eslint-disable-next-line no-console */
if (!w.support) { return console.log('NO WEBRTC SUPPORT') }
if (!wrtcSupport) { return console.log('NO WEBRTC SUPPORT') }

let peer1
let peer2
Expand Down
84 changes: 0 additions & 84 deletions test/turbolence.node.js

This file was deleted.

4 changes: 3 additions & 1 deletion test/utils/bundle-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const WebSocketStar = require('libp2p-websocket-star')
const Bootstrap = require('libp2p-bootstrap')
const SPDY = require('libp2p-spdy')
const MPLEX = require('libp2p-mplex')
const PULLMPLEX = require('pull-mplex')
const KadDHT = require('libp2p-kad-dht')
const SECIO = require('libp2p-secio')
const defaultsDeep = require('@nodeutils/defaults-deep')
Expand All @@ -17,6 +18,7 @@ function mapMuxers (list) {
switch (pref.trim().toLowerCase()) {
case 'spdy': return SPDY
case 'mplex': return MPLEX
case 'pullmplex': return PULLMPLEX
default:
throw new Error(pref + ' muxer not available')
}
Expand All @@ -27,7 +29,7 @@ function getMuxers (options) {
if (options) {
return mapMuxers(options)
} else {
return [MPLEX, SPDY]
return [PULLMPLEX, MPLEX, SPDY]
}
}

Expand Down
4 changes: 3 additions & 1 deletion test/utils/bundle-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Bootstrap = require('libp2p-bootstrap')
const SPDY = require('libp2p-spdy')
const KadDHT = require('libp2p-kad-dht')
const MPLEX = require('libp2p-mplex')
const PULLMPLEX = require('pull-mplex')
const SECIO = require('libp2p-secio')
const defaultsDeep = require('@nodeutils/defaults-deep')
const libp2p = require('../..')
Expand All @@ -17,6 +18,7 @@ function mapMuxers (list) {
switch (pref.trim().toLowerCase()) {
case 'spdy': return SPDY
case 'mplex': return MPLEX
case 'pullmplex': return PULLMPLEX
default:
throw new Error(pref + ' muxer not available')
}
Expand All @@ -30,7 +32,7 @@ function getMuxers (muxers) {
} else if (muxers) {
return mapMuxers(muxers)
} else {
return [MPLEX, SPDY]
return [PULLMPLEX, MPLEX, SPDY]
}
}

Expand Down

0 comments on commit 1879101

Please sign in to comment.