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 @@ -145,6 +145,8 @@ class ConnectionFSM extends BaseConnection {
145
145
dial ( ) {
146
146
if ( this . theirB58Id === this . ourPeerInfo . id . toB58String ( ) ) {
147
147
return this . emit ( 'error' , Errors . DIAL_SELF ( ) )
148
+ } else if ( this . getState ( ) === 'DIALING' ) {
149
+ return this . log ( 'attempted to dial while already dialing, ignoring' )
148
150
}
149
151
150
152
this . _state ( 'dial' )
Original file line number Diff line number Diff line change @@ -137,6 +137,20 @@ describe('ConnectionFSM', () => {
137
137
connection . dial ( )
138
138
} )
139
139
140
+ it ( 'should ignore concurrent dials' , ( ) => {
141
+ const connection = new ConnectionFSM ( {
142
+ _switch : dialerSwitch ,
143
+ peerInfo : listenerSwitch . _peerInfo
144
+ } )
145
+
146
+ const stub = sinon . stub ( connection , '_onDialing' )
147
+
148
+ connection . dial ( )
149
+ connection . dial ( )
150
+
151
+ expect ( stub . callCount ) . to . equal ( 1 )
152
+ } )
153
+
140
154
it ( 'should be able to encrypt a basic connection' , ( done ) => {
141
155
const connection = new ConnectionFSM ( {
142
156
_switch : dialerSwitch ,
You can’t perform that action at this time.
0 commit comments