mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-11 11:46:05 +00:00
* feat: new super simplified API * feat: append peer id to multiaddr if not there * [WIP] Awesome DHT (#86) * feat: integrate dht * better interfaces * docs: add documentation for peerRouting, contentRouting, dht * fix: take in passed datastore * fix: update usage of _getPeerInfo * fix: getPeerInfo * docs: update docs * moar feat: correctly handle p2p-circuit addrs when creating a peer info object refactor: rework config options * feat: adding circuit relaying * feat: rework circuit relay for protobufs * feat: circuit loading and tests * fix: clean up _getPeerInfo to work with /p2p-circuit * wip: tests cleaup * test: clean up * wip * fix: bringing back test reworks and new aegir * test: group tests * test: clean up * test: adjust test * fix: use getPeerId to determine if the ipfs fragment is missing * feat: adding circuit relaying * feat: circuit loading and tests * test: clean up * wip * feat: upgrade to latest aegir * fix: removing unused tests * feat: cleanup tests * fix: create node defautl options * chore: upgrade swarm to latest version * fix: updated aegir and adjust timeouts * feat: more timeouts * chore: updating deps * fix: circle ci builds * test: timeouts
103 lines
2.4 KiB
JavaScript
103 lines
2.4 KiB
JavaScript
/* eslint-env mocha */
|
|
'use strict'
|
|
|
|
const chai = require('chai')
|
|
chai.use(require('dirty-chai'))
|
|
const expect = chai.expect
|
|
const signalling = require('libp2p-webrtc-star/src/sig-server')
|
|
const parallel = require('async/parallel')
|
|
const utils = require('./utils')
|
|
const createNode = utils.createNode
|
|
const echo = utils.echo
|
|
|
|
describe('discovery', () => {
|
|
let nodeA
|
|
let nodeB
|
|
let port = 24642
|
|
let ss
|
|
|
|
function setup (options) {
|
|
before((done) => {
|
|
port++
|
|
parallel([
|
|
(cb) => {
|
|
signalling.start({ port: port }, (err, server) => {
|
|
expect(err).to.not.exist()
|
|
ss = server
|
|
cb()
|
|
})
|
|
},
|
|
(cb) => createNode([
|
|
'/ip4/0.0.0.0/tcp/0',
|
|
`/ip4/127.0.0.1/tcp/${port}/ws/p2p-webrtc-star`
|
|
], options, (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',
|
|
`/ip4/127.0.0.1/tcp/${port}/ws/p2p-webrtc-star`
|
|
], options, (err, node) => {
|
|
expect(err).to.not.exist()
|
|
nodeB = node
|
|
node.handle('/echo/1.0.0', echo)
|
|
node.start(cb)
|
|
})
|
|
], done)
|
|
})
|
|
|
|
after((done) => {
|
|
parallel([
|
|
(cb) => nodeA.stop(cb),
|
|
(cb) => nodeB.stop(cb),
|
|
(cb) => ss.stop(done)
|
|
], done)
|
|
})
|
|
}
|
|
|
|
describe('MulticastDNS', () => {
|
|
setup({ mdns: true })
|
|
|
|
it('find a peer', function (done) {
|
|
this.timeout(15000)
|
|
nodeA.once('peer:discovery', (peerInfo) => {
|
|
expect(nodeB.peerInfo.id.toB58String())
|
|
.to.eql(peerInfo.id.toB58String())
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
|
|
// TODO needs a delay (this test is already long)
|
|
describe.skip('WebRTCStar', () => {
|
|
setup({ webRTCStar: true })
|
|
|
|
it('find a peer', function (done) {
|
|
this.timeout(15000)
|
|
nodeA.once('peer:discovery', (peerInfo) => {
|
|
expect(nodeB.peerInfo.id.toB58String())
|
|
.to.eql(peerInfo.id.toB58String())
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('MulticastDNS + WebRTCStar', () => {
|
|
setup({
|
|
webRTCStar: true,
|
|
mdns: true
|
|
})
|
|
|
|
it('find a peer', function (done) {
|
|
this.timeout(15000)
|
|
nodeA.once('peer:discovery', (peerInfo) => {
|
|
expect(nodeB.peerInfo.id.toB58String())
|
|
.to.eql(peerInfo.id.toB58String())
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
})
|