mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 10:32:14 +00:00
test: update tests to use libp2p-mplex module
This commit is contained in:
parent
10a8ec3f31
commit
14d3578eaf
@ -60,14 +60,14 @@ describe('stream muxing', () => {
|
|||||||
], done)
|
], done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('multiplex only', (done) => {
|
it('mplex only', (done) => {
|
||||||
let nodeA
|
let nodeA
|
||||||
let nodeB
|
let nodeB
|
||||||
|
|
||||||
function setup (callback) {
|
function setup (callback) {
|
||||||
parallel([
|
parallel([
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['multiplex']
|
muxer: ['mplex']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeA = node
|
nodeA = node
|
||||||
@ -75,7 +75,7 @@ describe('stream muxing', () => {
|
|||||||
node.start(cb)
|
node.start(cb)
|
||||||
}),
|
}),
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['multiplex']
|
muxer: ['mplex']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeB = node
|
nodeB = node
|
||||||
@ -92,7 +92,7 @@ describe('stream muxing', () => {
|
|||||||
], done)
|
], done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('spdy + multiplex', function (done) {
|
it('spdy + mplex', function (done) {
|
||||||
this.timeout(5000)
|
this.timeout(5000)
|
||||||
|
|
||||||
let nodeA
|
let nodeA
|
||||||
@ -101,7 +101,7 @@ describe('stream muxing', () => {
|
|||||||
function setup (callback) {
|
function setup (callback) {
|
||||||
parallel([
|
parallel([
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['spdy', 'multiplex']
|
muxer: ['spdy', 'mplex']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeA = node
|
nodeA = node
|
||||||
@ -109,7 +109,7 @@ describe('stream muxing', () => {
|
|||||||
node.start(cb)
|
node.start(cb)
|
||||||
}),
|
}),
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['spdy', 'multiplex']
|
muxer: ['spdy', 'mplex']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeB = node
|
nodeB = node
|
||||||
@ -126,7 +126,7 @@ describe('stream muxing', () => {
|
|||||||
], done)
|
], done)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('spdy + multiplex switched order', function (done) {
|
it('spdy + mplex switched order', function (done) {
|
||||||
this.timeout(5 * 1000)
|
this.timeout(5 * 1000)
|
||||||
|
|
||||||
let nodeA
|
let nodeA
|
||||||
@ -135,7 +135,7 @@ describe('stream muxing', () => {
|
|||||||
function setup (callback) {
|
function setup (callback) {
|
||||||
parallel([
|
parallel([
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['spdy', 'multiplex']
|
muxer: ['spdy', 'mplex']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeA = node
|
nodeA = node
|
||||||
@ -143,7 +143,7 @@ describe('stream muxing', () => {
|
|||||||
node.start(cb)
|
node.start(cb)
|
||||||
}),
|
}),
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['multiplex', 'spdy']
|
muxer: ['mplex', 'spdy']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeB = node
|
nodeB = node
|
||||||
@ -177,7 +177,7 @@ describe('stream muxing', () => {
|
|||||||
node.start(cb)
|
node.start(cb)
|
||||||
}),
|
}),
|
||||||
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
(cb) => createNode('/ip4/0.0.0.0/tcp/0', {
|
||||||
muxer: ['multiplex']
|
muxer: ['mplex']
|
||||||
}, (err, node) => {
|
}, (err, node) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
nodeB = node
|
nodeB = node
|
||||||
|
@ -48,12 +48,12 @@ describe('transports', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('create libp2pNode with multiplex only', (done) => {
|
it('create libp2pNode with mplex only', (done) => {
|
||||||
PeerInfo.create((err, peerInfo) => {
|
PeerInfo.create((err, peerInfo) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
const b = new Node(peerInfo, null, { muxer: ['multiplex'] })
|
const b = new Node(peerInfo, null, { muxer: ['mplex'] })
|
||||||
expect(b.modules.connection.muxer).to.eql([require('libp2p-multiplex')])
|
expect(b.modules.connection.muxer).to.eql([require('libp2p-mplex')])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -4,7 +4,7 @@ const WS = require('libp2p-websockets')
|
|||||||
const WebRTCStar = require('libp2p-webrtc-star')
|
const WebRTCStar = require('libp2p-webrtc-star')
|
||||||
const WebSocketStar = require('libp2p-websocket-star')
|
const WebSocketStar = require('libp2p-websocket-star')
|
||||||
const spdy = require('libp2p-spdy')
|
const spdy = require('libp2p-spdy')
|
||||||
const multiplex = require('libp2p-multiplex')
|
const mplex = require('libp2p-mplex')
|
||||||
const secio = require('libp2p-secio')
|
const secio = require('libp2p-secio')
|
||||||
const Railing = require('libp2p-railing')
|
const Railing = require('libp2p-railing')
|
||||||
const libp2p = require('../..')
|
const libp2p = require('../..')
|
||||||
@ -17,8 +17,8 @@ function mapMuxers (list) {
|
|||||||
switch (pref.trim().toLowerCase()) {
|
switch (pref.trim().toLowerCase()) {
|
||||||
case 'spdy':
|
case 'spdy':
|
||||||
return spdy
|
return spdy
|
||||||
case 'multiplex':
|
case 'mplex':
|
||||||
return multiplex
|
return mplex
|
||||||
default:
|
default:
|
||||||
throw new Error(pref + ' muxer not available')
|
throw new Error(pref + ' muxer not available')
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ function getMuxers (options) {
|
|||||||
if (options) {
|
if (options) {
|
||||||
return mapMuxers(options)
|
return mapMuxers(options)
|
||||||
} else {
|
} else {
|
||||||
return [multiplex, spdy]
|
return [mplex, spdy]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const WS = require('libp2p-websockets')
|
|||||||
const Railing = require('libp2p-railing')
|
const Railing = require('libp2p-railing')
|
||||||
const spdy = require('libp2p-spdy')
|
const spdy = require('libp2p-spdy')
|
||||||
const KadDHT = require('libp2p-kad-dht')
|
const KadDHT = require('libp2p-kad-dht')
|
||||||
const multiplex = require('libp2p-multiplex')
|
const mplex = require('libp2p-mplex')
|
||||||
const secio = require('libp2p-secio')
|
const secio = require('libp2p-secio')
|
||||||
const libp2p = require('../..')
|
const libp2p = require('../..')
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ function mapMuxers (list) {
|
|||||||
}
|
}
|
||||||
switch (pref.trim().toLowerCase()) {
|
switch (pref.trim().toLowerCase()) {
|
||||||
case 'spdy': return spdy
|
case 'spdy': return spdy
|
||||||
case 'multiplex': return multiplex
|
case 'mplex': return mplex
|
||||||
default:
|
default:
|
||||||
throw new Error(pref + ' muxer not available')
|
throw new Error(pref + ' muxer not available')
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ function getMuxers (muxers) {
|
|||||||
} else if (muxers) {
|
} else if (muxers) {
|
||||||
return mapMuxers(muxers)
|
return mapMuxers(muxers)
|
||||||
} else {
|
} else {
|
||||||
return [multiplex, spdy]
|
return [mplex, spdy]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user