Compare commits

...

15 Commits

Author SHA1 Message Date
Jacob Heun
3bde9c8bed chore: release version v0.24.4 2019-01-04 10:15:49 -07:00
Jacob Heun
14e12ee1f1 chore: update contributors 2019-01-04 10:15:48 -07:00
Alan Shaw
2374929990 chore: update deps
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
2019-01-04 10:11:49 -07:00
Jacob Heun
26de739bb1 chore: 2019 q1 okrs planning (#293)
* chore: add q1 2019 okr section

* docs: add proposed okr items

* chore: update OKR.md

* chore: remove quic transport

* chore: add thoughts on okr priorities

* chore: add detailed interop tests

* chore: add line for floodsub interop

* chore: move q1 okrs to the google spreadsheet
2018-12-17 12:20:12 +01:00
Jacob Heun
0f8d6afd8f chore: release version v0.24.3 2018-12-14 17:57:32 +01:00
Jacob Heun
daa26859e0 chore: update contributors 2018-12-14 17:57:31 +01:00
Jacob Heun
fdfb7b4e86 fix: not started yet (#297)
* fix: callback when not started rather than throwing asserts

* fix: dont remove transports until the switch has stopped

* test: update connection check logic

* test: fix variable reference

* chore: update switch dep

* chore: update switch dep
2018-12-14 17:54:32 +01:00
Jacob Heun
15bdb795a4 chore: release version v0.24.2 2018-12-04 17:10:52 +01:00
Jacob Heun
7d78728f54 chore: update contributors 2018-12-04 17:10:52 +01:00
Jacob Heun
53ed3bdb99 fix: use symbol instead of constructor name (#292) 2018-12-04 16:04:17 +01:00
Jacob Heun
ae513887f5 chore: release version v0.24.1 2018-12-03 12:56:51 +01:00
Jacob Heun
7c78faa171 chore: update contributors 2018-12-03 12:56:50 +01:00
Vasco Santos
7d12eb9e26 feat: allow configurable validators and selectors to the dht (#288)
* feat: allow configurable validators and selectors to the dht

* chore: remove fallback
2018-11-29 15:10:23 +01:00
Marcin Tojek
581a1de472 docs: merge example links: Peer and Content Routing (#285) 2018-11-20 13:40:38 +01:00
Jacob Heun
288ac17954 chore: update changelog 2018-11-16 14:31:13 +01:00
12 changed files with 220 additions and 86 deletions

View File

@@ -1,7 +1,58 @@
<a name="0.24.4"></a>
## [0.24.4](https://github.com/libp2p/js-libp2p/compare/v0.24.3...v0.24.4) (2019-01-04)
<a name="0.24.3"></a>
## [0.24.3](https://github.com/libp2p/js-libp2p/compare/v0.24.2...v0.24.3) (2018-12-14)
### Bug Fixes
* not started yet ([#297](https://github.com/libp2p/js-libp2p/issues/297)) ([fdfb7b4](https://github.com/libp2p/js-libp2p/commit/fdfb7b4))
<a name="0.24.2"></a>
## [0.24.2](https://github.com/libp2p/js-libp2p/compare/v0.24.1...v0.24.2) (2018-12-04)
### Bug Fixes
* use symbol instead of constructor name ([#292](https://github.com/libp2p/js-libp2p/issues/292)) ([53ed3bd](https://github.com/libp2p/js-libp2p/commit/53ed3bd))
<a name="0.24.1"></a>
## [0.24.1](https://github.com/libp2p/js-libp2p/compare/v0.24.0...v0.24.1) (2018-12-03)
### Features
* allow configurable validators and selectors to the dht ([#288](https://github.com/libp2p/js-libp2p/issues/288)) ([7d12eb9](https://github.com/libp2p/js-libp2p/commit/7d12eb9))
<a name="0.24.0"></a>
# [0.24.0](https://github.com/libp2p/js-libp2p/compare/v0.24.0-rc.3...v0.24.0) (2018-11-16)
### Bug Fixes
* add maxtimeout to dht get ([#248](https://github.com/libp2p/js-libp2p/issues/248)) ([69f7264](https://github.com/libp2p/js-libp2p/commit/69f7264))
* dht get options ([4460e82](https://github.com/libp2p/js-libp2p/commit/4460e82))
* dont call callback before it's properly set ([17b5f73](https://github.com/libp2p/js-libp2p/commit/17b5f73))
* improve get peer info errors ([714b6ec](https://github.com/libp2p/js-libp2p/commit/714b6ec))
* start kad dht random walk ([#251](https://github.com/libp2p/js-libp2p/issues/251)) ([dd934b9](https://github.com/libp2p/js-libp2p/commit/dd934b9))
### Features
* add datastore to config ([40e840d](https://github.com/libp2p/js-libp2p/commit/40e840d))
* add delegated peer and content routing support ([#242](https://github.com/libp2p/js-libp2p/issues/242)) ([a95389a](https://github.com/libp2p/js-libp2p/commit/a95389a))
* add maxNumProviders to findprovs ([#283](https://github.com/libp2p/js-libp2p/issues/283)) ([970deec](https://github.com/libp2p/js-libp2p/commit/970deec))
* conditionally emit errors ([f71fdfd](https://github.com/libp2p/js-libp2p/commit/f71fdfd))
* enable relay by default (no hop) ([#254](https://github.com/libp2p/js-libp2p/issues/254)) ([686379e](https://github.com/libp2p/js-libp2p/commit/686379e))
* make libp2p a state machine ([#257](https://github.com/libp2p/js-libp2p/issues/257)) ([0b75f99](https://github.com/libp2p/js-libp2p/commit/0b75f99))
* use package-table vs custom script ([a63432e](https://github.com/libp2p/js-libp2p/commit/a63432e))
<a name="0.23.1"></a>
## [0.23.1](https://github.com/libp2p/js-libp2p/compare/v0.23.0...v0.23.1) (2018-08-13)

4
OKR.md
View File

@@ -2,6 +2,10 @@
We try to frame our ongoing work using a process based on quarterly Objectives and Key Results (OKRs). Objectives reflect outcomes that are challenging, but realistic. Results are tangible and measurable.
## 2019 Q1
Find the js-libp2p OKRs for 2019 Q1 at the [2019 Q1 libp2p OKRs Spreadsheet](https://docs.google.com/spreadsheets/d/11GKG1DBRIIAiQnHvLD7_IqWxDGsVdaZFpxJM6NWtXe8/edit#gid=1271182838)
## 2018 Q4
Find the js-libp2p OKRs for 2018 Q4 at the [2018 Q4 libp2p OKRs Spreadsheet](https://docs.google.com/spreadsheets/d/1BYwmbVicgo6_tOHAbgiUXWge8Ej0qR1M_gAUulazmrg/edit#gid=1241853194)

View File

@@ -10,8 +10,7 @@ Let us know if you find any issue or if you want to contribute and add a new tut
- [Protocol and Stream Muxing](./protocol-and-stream-muxing)
- [Encrypted Communications](./encrypted-communications)
- [Discovery Mechanisms](./discovery-mechanisms)
- [Peer Routing](./peer-and-content-routing)
- [Content Routing](./peer-and-content-routing)
- [Peer and Content Routing](./peer-and-content-routing)
- [PubSub](./pubsub)
- [NAT Traversal](./nat-traversal)
- Circuit Relay (future)

View File

@@ -1,6 +1,6 @@
{
"name": "libp2p",
"version": "0.24.0",
"version": "0.24.4",
"description": "JavaScript base class for libp2p bundles",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",
@@ -50,17 +50,17 @@
"libp2p-connection-manager": "~0.0.2",
"libp2p-floodsub": "~0.15.1",
"libp2p-ping": "~0.8.3",
"libp2p-switch": "~0.41.2",
"libp2p-switch": "~0.41.3",
"libp2p-websockets": "~0.12.0",
"mafmt": "^6.0.2",
"multiaddr": "^5.0.2",
"peer-book": "~0.8.0",
"multiaddr": "^6.0.2",
"peer-book": "~0.9.0",
"peer-id": "~0.12.0",
"peer-info": "~0.14.1"
"peer-info": "~0.15.0"
},
"devDependencies": {
"@nodeutils/defaults-deep": "^1.1.0",
"aegir": "^17.0.1",
"aegir": "^18.0.2",
"chai": "^4.2.0",
"chai-checkmark": "^1.0.1",
"cids": "~0.5.5",
@@ -71,15 +71,15 @@
"libp2p-circuit": "~0.3.0",
"libp2p-delegated-content-routing": "~0.2.2",
"libp2p-delegated-peer-routing": "~0.2.2",
"libp2p-kad-dht": "~0.11.1",
"libp2p-kad-dht": "~0.14.2",
"libp2p-mdns": "~0.12.0",
"libp2p-mplex": "~0.8.4",
"libp2p-secio": "~0.10.1",
"libp2p-secio": "~0.11.0",
"libp2p-spdy": "~0.13.0",
"libp2p-tcp": "~0.13.0",
"libp2p-webrtc-star": "~0.15.5",
"libp2p-websocket-star": "~0.9.0",
"libp2p-websocket-star-rendezvous": "~0.2.4",
"libp2p-websocket-star": "~0.10.1",
"libp2p-websocket-star-rendezvous": "~0.3.0",
"lodash.times": "^4.3.2",
"nock": "^10.0.2",
"pull-goodbye": "0.0.2",
@@ -90,6 +90,7 @@
"wrtc": "~0.3.2"
},
"contributors": [
"Alan Shaw <alan.shaw@protocol.ai>",
"Alan Shaw <alan@tableflip.io>",
"Chris Bratlien <chrisbratlien@gmail.com>",
"Chris Dostert <chrisdostert@users.noreply.github.com>",
@@ -111,6 +112,7 @@
"Kevin Kwok <antimatter15@gmail.com>",
"Lars Gierth <lgierth@users.noreply.github.com>",
"Maciej Krüger <mkg20001@gmail.com>",
"Marcin Tojek <mtojek@users.noreply.github.com>",
"Nuno Nogueira <nunofmn@gmail.com>",
"Pedro Teixeira <pedro@protocol.ai>",
"Pedro Teixeira <i@pgte.me>",

View File

@@ -32,9 +32,11 @@ const OptionsSchema = Joi.object({
})
}).default(),
dht: Joi.object().keys({
kBucketSize: Joi.number().allow(null),
enabledDiscovery: Joi.boolean().default(true)
}),
kBucketSize: Joi.number().default(20),
enabledDiscovery: Joi.boolean().default(true),
validators: Joi.object().allow(null),
selectors: Joi.object().allow(null)
}).default(),
EXPERIMENTAL: Joi.object().keys({
dht: Joi.boolean().default(false),
pubsub: Joi.boolean().default(false)

View File

@@ -2,10 +2,10 @@
const FSM = require('fsm-event')
const EventEmitter = require('events').EventEmitter
const assert = require('assert')
const debug = require('debug')
const log = debug('libp2p')
log.error = debug('libp2p:error')
const errCode = require('err-code')
const each = require('async/each')
const series = require('async/series')
@@ -24,7 +24,12 @@ const pubsub = require('./pubsub')
const getPeerInfo = require('./get-peer-info')
const validateConfig = require('./config').validate
const NOT_STARTED_ERROR_MESSAGE = 'The libp2p node is not started yet'
const notStarted = (action, state) => {
return errCode(
new Error(`libp2p cannot ${action} when not started; state is ${state}`),
'ERR_NODE_NOT_STARTED'
)
}
/**
* @fires Node#error Emitted when an error occurs
@@ -102,9 +107,11 @@ class Node extends EventEmitter {
const enabledDiscovery = this._config.dht.enabledDiscovery !== false
this._dht = new DHT(this._switch, {
kBucketSize: this._config.dht.kBucketSize || 20,
kBucketSize: this._config.dht.kBucketSize,
enabledDiscovery,
datastore: this.datastore
datastore: this.datastore,
validators: this._config.dht.validators,
selectors: this._config.dht.selectors
})
}
@@ -215,8 +222,6 @@ class Node extends EventEmitter {
* @returns {void}
*/
dial (peer, callback) {
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE)
this.dialProtocol(peer, null, callback)
}
@@ -231,7 +236,9 @@ class Node extends EventEmitter {
* @returns {void}
*/
dialProtocol (peer, protocol, callback) {
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE)
if (!this.isStarted()) {
return callback(notStarted('dial', this.state._state))
}
if (typeof protocol === 'function') {
callback = protocol
@@ -259,7 +266,9 @@ class Node extends EventEmitter {
* @returns {void}
*/
dialFSM (peer, protocol, callback) {
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE)
if (!this.isStarted()) {
return callback(notStarted('dial', this.state._state))
}
if (typeof protocol === 'function') {
callback = protocol
@@ -280,8 +289,6 @@ class Node extends EventEmitter {
}
hangUp (peer, callback) {
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE)
this._getPeerInfo(peer, (err, peerInfo) => {
if (err) { return callback(err) }
@@ -291,7 +298,7 @@ class Node extends EventEmitter {
ping (peer, callback) {
if (!this.isStarted()) {
return callback(new Error(NOT_STARTED_ERROR_MESSAGE))
return callback(notStarted('ping', this.state._state))
}
this._getPeerInfo(peer, (err, peerInfo) => {
@@ -340,7 +347,7 @@ class Node extends EventEmitter {
}
if (t.filter(multiaddrs).length > 0) {
this._switch.transport.add(t.tag || t.constructor.name, t)
this._switch.transport.add(t.tag || t[Symbol.toStringTag], t)
} else if (WebSockets.isWebSockets(t)) {
// TODO find a cleaner way to signal that a transport is always used
// for dialing, even if no listener
@@ -461,13 +468,13 @@ class Node extends EventEmitter {
}
cb()
},
(cb) => {
// Ensures idempotency for restarts
this._switch.transport.removeAll(cb)
},
(cb) => {
this.connectionManager.stop()
this._switch.stop(cb)
},
(cb) => {
// Ensures idempotent restarts
this._switch.transport.removeAll(cb)
}
], (err) => {
if (err) {

View File

@@ -11,6 +11,7 @@ const WS = require('libp2p-websockets')
const Bootstrap = require('libp2p-bootstrap')
const DelegatedPeerRouter = require('libp2p-delegated-peer-routing')
const DelegatedContentRouter = require('libp2p-delegated-content-routing')
const DHT = require('libp2p-kad-dht')
const validateConfig = require('../src/config').validate
@@ -91,6 +92,10 @@ describe('configuration', () => {
pubsub: false,
dht: false
},
dht: {
kBucketSize: 20,
enabledDiscovery: true
},
relay: {
enabled: true
}
@@ -143,4 +148,49 @@ describe('configuration', () => {
expect(() => validateConfig(options)).to.throw()
})
it('should add defaults, validators and selectors for dht', () => {
const selectors = {}
const validators = {}
const options = {
peerInfo,
modules: {
transport: [WS],
dht: DHT
},
config: {
EXPERIMENTAL: {
dht: true
},
dht: {
selectors,
validators
}
}
}
const expected = {
peerInfo,
modules: {
transport: [WS],
dht: DHT
},
config: {
EXPERIMENTAL: {
pubsub: false,
dht: true
},
relay: {
enabled: true
},
dht: {
kBucketSize: 20,
enabledDiscovery: true,
selectors,
validators
}
}
}
expect(validateConfig(options)).to.deep.equal(expected)
})
})

View File

@@ -114,5 +114,29 @@ describe('libp2p state machine (fsm)', () => {
node.start()
})
it('should not dial when the node is stopped', (done) => {
node.on('stop', () => {
node.dial(null, (err) => {
expect(err).to.exist()
expect(err.code).to.eql('ERR_NODE_NOT_STARTED')
done()
})
})
node.stop()
})
it('should not dial (fsm) when the node is stopped', (done) => {
node.on('stop', () => {
node.dialFSM(null, null, (err) => {
expect(err).to.exist()
expect(err.code).to.eql('ERR_NODE_NOT_STARTED')
done()
})
})
node.stop()
})
})
})

View File

@@ -215,7 +215,7 @@ describe('stream muxing', () => {
nodeA.dial(nodeB.peerInfo, (err) => {
expect(err).to.not.exist()
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
cb()
})
},

View File

@@ -102,7 +102,7 @@ describe('transports', () => {
function check () {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
done()
}
})
@@ -142,7 +142,7 @@ describe('transports', () => {
const peers = nodeA.peerBook.getAll()
expect(err).to.not.exist()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
done()
}
})
@@ -153,16 +153,17 @@ describe('transports', () => {
expect(err).to.not.exist()
connFSM.once('muxed', () => {
expect(nodeA._switch.muxedConns).to.have.any.keys(
peerB.id.toB58String()
)
expect(
nodeA._switch.connection.getAllById(peerB.id.toB58String())
).to.have.length(1)
connFSM.once('error', done)
connFSM.once('close', () => {
// ensure the connection is closed
expect(nodeA._switch.muxedConns).to.not.have.any.keys([
peerB.id.toB58String()
])
expect(
nodeA._switch.connection.getAllById(peerB.id.toB58String())
).to.have.length(0)
done()
})
@@ -312,7 +313,7 @@ describe('transports', () => {
function check () {
const peers = node1.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(node1._switch.muxedConns)).to.have.length(0)
expect(node1._switch.connection.getAll()).to.have.length(0)
done()
}
})
@@ -326,7 +327,7 @@ describe('transports', () => {
function check () {
// Verify both nodes are connected to node 3
if (node1._switch.muxedConns[b58Id] && node2._switch.muxedConns[b58Id]) {
if (node1._switch.connection.getAllById(b58Id) && node2._switch.connection.getAllById(b58Id)) {
done()
}
}
@@ -417,7 +418,7 @@ describe('transports', () => {
function check () {
const peers = node1.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(node1._switch.muxedConns)).to.have.length(0)
expect(node1._switch.connection.getAll()).to.have.length(0)
done()
}
})
@@ -430,8 +431,8 @@ describe('transports', () => {
function check () {
if (++counter === 3) {
expect(Object.keys(node1._switch.muxedConns).length).to.equal(1)
expect(Object.keys(node2._switch.muxedConns).length).to.equal(1)
expect(node1._switch.connection.getAll()).to.have.length(1)
expect(node2._switch.connection.getAll()).to.have.length(1)
done()
}
}

View File

@@ -91,14 +91,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeB._switch.muxedConns)).to.have.length(0)
expect(nodeB._switch.connection.getAll()).to.have.length(0)
cb()
}
], done)
@@ -117,15 +116,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(1)
expect(nodeA._switch.connection.getAll()).to.have.length(1)
cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(1)
expect(nodeA._switch.connection.getAll()).to.have.length(1)
cb()
}
], () => tryEcho(conn, done))
@@ -143,15 +140,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeB._switch.muxedConns)).to.have.length(0)
expect(nodeB._switch.connection.getAll()).to.have.length(0)
cb()
}
], done)
@@ -170,13 +165,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(1)
expect(nodeA._switch.connection.getAll()).to.have.length(1)
cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(1)
expect(nodeA._switch.connection.getAll()).to.have.length(1)
cb()
}
], () => tryEcho(conn, done))
@@ -194,13 +189,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA._switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
cb()
},
(cb) => {
const peers = nodeB.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeB._switch.muxedConns)).to.have.length(0)
expect(nodeB._switch.connection.getAll()).to.have.length(0)
cb()
}
], done)
@@ -213,16 +208,16 @@ describe('transports', () => {
expect(err).to.not.exist()
connFSM.once('muxed', () => {
expect(nodeA._switch.muxedConns).to.have.any.keys(
nodeB.peerInfo.id.toB58String()
)
expect(
nodeA._switch.connection.getAllById(nodeB.peerInfo.id.toB58String())
).to.have.length(1)
connFSM.once('error', done)
connFSM.once('close', () => {
// ensure the connection is closed
expect(nodeA._switch.muxedConns).to.not.have.any.keys([
nodeB.peerInfo.id.toB58String()
])
expect(
nodeA._switch.connection.getAllById(nodeB.peerInfo.id.toB58String())
).to.have.length(0)
done()
})
@@ -235,9 +230,9 @@ describe('transports', () => {
nodeA.dialFSM(nodeB.peerInfo, '/echo/1.0.0', (err, connFSM) => {
expect(err).to.not.exist()
connFSM.once('connection', (conn) => {
expect(nodeA._switch.muxedConns).to.have.all.keys([
nodeB.peerInfo.id.toB58String()
])
expect(
nodeA._switch.connection.getAllById(nodeB.peerInfo.id.toB58String())
).to.have.length(1)
tryEcho(conn, () => {
connFSM.close()
})
@@ -245,9 +240,9 @@ describe('transports', () => {
connFSM.once('error', done)
connFSM.once('close', () => {
// ensure the connection is closed
expect(nodeA._switch.muxedConns).to.not.have.any.keys([
nodeB.peerInfo.id.toB58String()
])
expect(
nodeA._switch.connection.getAllById(nodeB.peerInfo.id.toB58String())
).to.have.length(0)
done()
})
})
@@ -309,13 +304,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeTCP.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeTCP._switch.muxedConns)).to.have.length(1)
expect(nodeTCP._switch.connection.getAll()).to.have.length(1)
cb()
},
(cb) => {
const peers = nodeTCPnWS.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeTCPnWS._switch.muxedConns)).to.have.length(1)
expect(nodeTCPnWS._switch.connection.getAll()).to.have.length(1)
cb()
}
], done)
@@ -333,14 +328,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeTCP.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeTCP._switch.muxedConns)).to.have.length(0)
expect(nodeTCP._switch.connection.getAll()).to.have.length(0)
cb()
},
(cb) => {
const peers = nodeTCPnWS.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeTCPnWS._switch.muxedConns)).to.have.length(0)
expect(nodeTCPnWS._switch.connection.getAll()).to.have.length(0)
cb()
}
], done)
@@ -360,13 +354,13 @@ describe('transports', () => {
(cb) => {
const peers = nodeTCPnWS.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(2)
expect(Object.keys(nodeTCPnWS._switch.muxedConns)).to.have.length(1)
expect(nodeTCPnWS._switch.connection.getAll()).to.have.length(1)
cb()
},
(cb) => {
const peers = nodeWS.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeWS._switch.muxedConns)).to.have.length(1)
expect(nodeWS._switch.connection.getAll()).to.have.length(1)
cb()
}
], done)
@@ -384,14 +378,14 @@ describe('transports', () => {
(cb) => {
const peers = nodeTCPnWS.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(2)
expect(Object.keys(nodeTCPnWS._switch.muxedConns)).to.have.length(0)
expect(nodeTCPnWS._switch.connection.getAll()).to.have.length(0)
cb()
},
(cb) => {
const peers = nodeWS.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeWS._switch.muxedConns)).to.have.length(0)
expect(nodeWS._switch.connection.getAll()).to.have.length(0)
cb()
}
], done)
@@ -427,7 +421,7 @@ describe('transports', () => {
cb()
}),
(cb) => {
const wstar = new WRTCStar({wrtc: wrtc})
const wstar = new WRTCStar({ wrtc: wrtc })
createNode([
'/ip4/0.0.0.0/tcp/0',
@@ -474,7 +468,7 @@ describe('transports', () => {
}),
(cb) => {
const wstar = new WRTCStar({wrtc: wrtc})
const wstar = new WRTCStar({ wrtc: wrtc })
createNode([
'/ip4/127.0.0.1/tcp/24642/ws/p2p-webrtc-star'
@@ -516,7 +510,7 @@ describe('transports', () => {
let i = 1;
[nodeAll, otherNode].forEach((node) => {
expect(Object.keys(node.peerBook.getAll())).to.have.length(i-- ? peers : 1)
expect(Object.keys(node._switch.muxedConns)).to.have.length(muxed)
expect(node._switch.connection.getAll()).to.have.length(muxed)
})
callback()
}
@@ -678,7 +672,7 @@ describe('transports', () => {
let i = 1;
[nodeAll, otherNode].forEach((node) => {
expect(Object.keys(node.peerBook.getAll())).to.have.length(i-- ? peers : 1)
expect(Object.keys(node._switch.muxedConns)).to.have.length(muxed)
expect(node._switch.connection.getAll()).to.have.length(muxed)
})
done()
}

View File

@@ -77,7 +77,7 @@ describe('Turbolence tests', () => {
function check () {
const peers = nodeA.peerBook.getAll()
expect(Object.keys(peers)).to.have.length(1)
expect(Object.keys(nodeA.switch.muxedConns)).to.have.length(0)
expect(nodeA._switch.connection.getAll()).to.have.length(0)
done()
}
})