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

fix: don't dial circuit if no transports available #236

Merged
merged 1 commit into from
Nov 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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