Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
fix: don't dial circuit if no transports available (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov authored and daviddias committed Nov 18, 2017
1 parent 661e75a commit f22ee2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/dial.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand Down

0 comments on commit f22ee2a

Please sign in to comment.