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

Commit f22ee2a

Browse files
dryajovdaviddias
authored andcommitted
fix: don't dial circuit if no transports available (#236)
1 parent 661e75a commit f22ee2a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/dial.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ function dial (swarm) {
8383
function attemptDial (pi, cb) {
8484
const tKeys = swarm.availableTransports(pi)
8585

86+
if (tKeys.length === 0) {
87+
return cb(new Error('No transports registered, dial not possible'))
88+
}
89+
8690
nextTransport(tKeys.shift())
8791

8892
function nextTransport (key) {

test/circuit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ describe(`circuit`, function () {
102102
})
103103
})
104104

105-
it(`should not try circuit if not enabled`, function (done) {
105+
it(`should not try circuit if no transports enabled`, function (done) {
106106
swarmC.dial(peerA, (err, conn) => {
107107
expect(err).to.exist()
108108
expect(conn).to.not.exist()
109109

110-
expect(err).to.match(/Could not dial in any of the transports or relays/)
110+
expect(err).to.match(/No transports registered, dial not possible/)
111111
done()
112112
})
113113
})

0 commit comments

Comments
 (0)