mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-29 17:01:37 +00:00
Protect from peers without supported transports
# What Trying to run compliance tests from the kad router module. I've tried to port the new swarm API but forgot to add a transport. The tests ended up blowing up instead of failing gracefully. # How to test ```js peerOne = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/8090')]) peerTwo = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/8091')]) swarm = new Swarm(peerZero) swarm.dial(peerTwo, {}, function (err) { console.log(err); }); ``` This just work and display the error.
This commit is contained in:
@ -13,17 +13,35 @@ var Swarm = require('../src')
|
||||
var tcp = require('libp2p-tcp')
|
||||
var Spdy = require('libp2p-spdy')
|
||||
|
||||
/* TODO
|
||||
experiment('Basics', function () {
|
||||
test('enforces creation with new', function (done) {done() })
|
||||
})
|
||||
*/
|
||||
|
||||
// because of Travis-CI
|
||||
process.on('uncaughtException', function (err) {
|
||||
console.log('Caught exception: ' + err)
|
||||
})
|
||||
|
||||
experiment('Basics', function () {
|
||||
test('enforces creation with new', function (done) {
|
||||
expect(function () {
|
||||
Swarm()
|
||||
}).to.throw()
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
experiment('When dialing', function () {
|
||||
experiment('if the swarm does add any of the peer transports', function () {
|
||||
test('it returns an error', function (done) {
|
||||
var peerOne = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/8090')])
|
||||
var peerTwo = new Peer(Id.create(), [multiaddr('/ip4/127.0.0.1/tcp/8091')])
|
||||
var swarm = new Swarm(peerOne)
|
||||
|
||||
swarm.dial(peerTwo, {}, function (err) {
|
||||
expect(err).to.exist()
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
experiment('Without a Stream Muxer', function () {
|
||||
experiment('tcp', function () {
|
||||
test('add the transport', function (done) {
|
||||
|
Reference in New Issue
Block a user