This repository was archived by the owner on Aug 23, 2019. It is now read-only.
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) {
130130 function dialCircuit ( cb ) {
131131 log ( `Falling back to dialing over circuit` )
132132 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+
133137 swarm . transport . dial ( Circuit . tag , pi , ( err , conn ) => {
134138 if ( err ) {
135139 log ( err )
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ describe(`circuit`, function () {
2121 let peerA
2222 let swarmB // WS
2323 let peerB
24+ let swarmC // no transports
2425 let peerC // just a peer
2526 let dialSpyA
2627
@@ -39,6 +40,7 @@ describe(`circuit`, function () {
3940
4041 swarmA = new Swarm ( peerA , new PeerBook ( ) )
4142 swarmB = new Swarm ( peerB , new PeerBook ( ) )
43+ swarmC = new Swarm ( peerC , new PeerBook ( ) )
4244
4345 swarmA . transport . add ( 'tcp' , new TCP ( ) )
4446 swarmA . transport . add ( 'WebSockets' , new WS ( ) )
@@ -100,6 +102,16 @@ describe(`circuit`, function () {
100102 } )
101103 } )
102104
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+
103115 it ( `should not dial circuit if other transport succeed` , function ( done ) {
104116 swarmA . dial ( peerB , ( err ) => {
105117 expect ( err ) . not . to . exist ( )
You can’t perform that action at this time.
0 commit comments