mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-13 17:21:21 +00:00
feat: (BREAKING CHANGE) overhaul libp2p config and constructor
* docs: update chat example and add info to its readme * docs: update echo example * docs: update libp2p in browser example * docs: update pubsub example * docs: update peer and content routing examples * docs: update discovery mechanisms example * docs: update encrypted comms example * docs: update protocol and stream muxing example * feat: add config validation * test: update CI configs, use only node 8
This commit is contained in:
39
test/multiaddr-trim.node.js
Normal file
39
test/multiaddr-trim.node.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* eslint-env mocha */
|
||||
'use strict'
|
||||
|
||||
const chai = require('chai')
|
||||
chai.use(require('dirty-chai'))
|
||||
const expect = chai.expect
|
||||
const series = require('async/series')
|
||||
|
||||
const createNode = require('./utils/create-node')
|
||||
|
||||
describe('multiaddr trim', () => {
|
||||
it('non used multiaddrs get trimmed', (done) => {
|
||||
let node
|
||||
|
||||
series([
|
||||
(cb) => createNode([
|
||||
'/ip4/0.0.0.0/tcp/999/wss/p2p-webrtc-direct',
|
||||
'/ip4/127.0.0.1/tcp/55555/ws',
|
||||
'/ip4/0.0.0.0/tcp/0/'
|
||||
], (err, _node) => {
|
||||
expect(err).to.not.exist()
|
||||
node = _node
|
||||
const multiaddrs = node.peerInfo.multiaddrs.toArray()
|
||||
expect(multiaddrs).to.have.length(3)
|
||||
cb()
|
||||
}),
|
||||
(cb) => node.start(cb)
|
||||
], (err) => {
|
||||
expect(err).to.not.exist()
|
||||
|
||||
const multiaddrs = node.peerInfo.multiaddrs.toArray()
|
||||
|
||||
expect(multiaddrs.length).to.at.least(2)
|
||||
expect(multiaddrs[0].toString())
|
||||
.to.match(/^\/ip4\/127\.0\.0\.1\/tcp\/[0-9]+\/ws\/ipfs\/\w+$/)
|
||||
node.stop(done)
|
||||
})
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user