diff --git a/src/dial.js b/src/dial.js index 8bb5c5a..c90a136 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 70d8cf9..b65a337 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() }) })