From f22ee2a21ca7648733f5dc9cf0da2a71b4916593 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sat, 18 Nov 2017 15:41:45 -0600 Subject: [PATCH] fix: don't dial circuit if no transports available (#236) --- src/dial.js | 4 ++++ test/circuit.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dial.js b/src/dial.js index 8bb5c5a2c0..c90a1368e6 100644 --- a/src/dial.js +++ b/src/dial.js @@ -83,6 +83,10 @@ function dial (swarm) { function attemptDial (pi, cb) { const tKeys = swarm.availableTransports(pi) + if (tKeys.length === 0) { + return cb(new Error('No transports registered, dial not possible')) + } + nextTransport(tKeys.shift()) function nextTransport (key) { diff --git a/test/circuit.js b/test/circuit.js index 70d8cf9a9f..b65a337666 100644 --- a/test/circuit.js +++ b/test/circuit.js @@ -102,12 +102,12 @@ describe(`circuit`, function () { }) }) - it(`should not try circuit if not enabled`, function (done) { + it(`should not try circuit if no transports enabled`, function (done) { swarmC.dial(peerA, (err, conn) => { expect(err).to.exist() expect(conn).to.not.exist() - expect(err).to.match(/Could not dial in any of the transports or relays/) + expect(err).to.match(/No transports registered, dial not possible/) done() }) })