File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ function dial (swarm) {
130
130
function dialCircuit ( cb ) {
131
131
log ( `Falling back to dialing over circuit` )
132
132
pi . multiaddrs . add ( `/p2p-circuit/ipfs/${ pi . id . toB58String ( ) } ` )
133
+ if ( ! swarm . transports [ Circuit . tag ] ) {
134
+ return cb ( new Error ( `Circuit not enabled!` ) )
135
+ }
136
+
133
137
swarm . transport . dial ( Circuit . tag , pi , ( err , conn ) => {
134
138
if ( err ) {
135
139
log ( err )
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ describe(`circuit`, function () {
21
21
let peerA
22
22
let swarmB // WS
23
23
let peerB
24
+ let swarmC // no transports
24
25
let peerC // just a peer
25
26
let dialSpyA
26
27
@@ -39,6 +40,7 @@ describe(`circuit`, function () {
39
40
40
41
swarmA = new Swarm ( peerA , new PeerBook ( ) )
41
42
swarmB = new Swarm ( peerB , new PeerBook ( ) )
43
+ swarmC = new Swarm ( peerC , new PeerBook ( ) )
42
44
43
45
swarmA . transport . add ( 'tcp' , new TCP ( ) )
44
46
swarmA . transport . add ( 'WebSockets' , new WS ( ) )
@@ -100,6 +102,16 @@ describe(`circuit`, function () {
100
102
} )
101
103
} )
102
104
105
+ it ( `should not try circuit if not enabled` , function ( done ) {
106
+ swarmC . dial ( peerA , ( err , conn ) => {
107
+ expect ( err ) . to . exist ( )
108
+ expect ( conn ) . to . not . exist ( )
109
+
110
+ expect ( err ) . to . match ( / C o u l d n o t d i a l i n a n y o f t h e t r a n s p o r t s o r r e l a y s / )
111
+ done ( )
112
+ } )
113
+ } )
114
+
103
115
it ( `should not dial circuit if other transport succeed` , function ( done ) {
104
116
swarmA . dial ( peerB , ( err ) => {
105
117
expect ( err ) . not . to . exist ( )
You can’t perform that action at this time.
0 commit comments