@@ -15,7 +15,7 @@ func getMockDialFunc() (dialWorkerFunc, func(), context.Context, <-chan struct{}
15
15
dfcalls := make (chan struct {}, 512 ) // buffer it large enough that we won't care
16
16
dialctx , cancel := context .WithCancel (context .Background ())
17
17
ch := make (chan struct {})
18
- f := func (p peer.ID , reqch <- chan dialRequest ) error {
18
+ f := func (p peer.ID , reqch <- chan dialRequest ) {
19
19
defer cancel ()
20
20
dfcalls <- struct {}{}
21
21
go func () {
@@ -24,7 +24,6 @@ func getMockDialFunc() (dialWorkerFunc, func(), context.Context, <-chan struct{}
24
24
req .resch <- dialResponse {conn : new (Conn )}
25
25
}
26
26
}()
27
- return nil
28
27
}
29
28
30
29
var once sync.Once
@@ -162,7 +161,7 @@ func TestDialSyncAllCancel(t *testing.T) {
162
161
163
162
func TestFailFirst (t * testing.T ) {
164
163
var count int32
165
- f := func (p peer.ID , reqch <- chan dialRequest ) error {
164
+ f := func (p peer.ID , reqch <- chan dialRequest ) {
166
165
go func () {
167
166
for {
168
167
req , ok := <- reqch
@@ -178,33 +177,29 @@ func TestFailFirst(t *testing.T) {
178
177
atomic .AddInt32 (& count , 1 )
179
178
}
180
179
}()
181
- return nil
182
180
}
183
181
184
182
ds := newDialSync (f )
185
-
186
183
p := peer .ID ("testing" )
187
184
188
185
ctx , cancel := context .WithTimeout (context .Background (), time .Second * 5 )
189
186
defer cancel ()
190
187
191
- _ , err := ds .Dial (ctx , p )
192
- if err == nil {
188
+ if _ , err := ds .Dial (ctx , p ); err == nil {
193
189
t .Fatal ("expected gophers to have eaten the modem" )
194
190
}
195
191
196
192
c , err := ds .Dial (ctx , p )
197
193
if err != nil {
198
194
t .Fatal (err )
199
195
}
200
-
201
196
if c == nil {
202
197
t .Fatal ("should have gotten a 'real' conn back" )
203
198
}
204
199
}
205
200
206
201
func TestStressActiveDial (t * testing.T ) {
207
- ds := newDialSync (func (p peer.ID , reqch <- chan dialRequest ) error {
202
+ ds := newDialSync (func (p peer.ID , reqch <- chan dialRequest ) {
208
203
go func () {
209
204
for {
210
205
req , ok := <- reqch
@@ -214,7 +209,6 @@ func TestStressActiveDial(t *testing.T) {
214
209
req .resch <- dialResponse {}
215
210
}
216
211
}()
217
- return nil
218
212
})
219
213
220
214
wg := sync.WaitGroup {}
@@ -235,24 +229,3 @@ func TestStressActiveDial(t *testing.T) {
235
229
236
230
wg .Wait ()
237
231
}
238
-
239
- func TestDialSelf (t * testing.T ) {
240
- ctx , cancel := context .WithCancel (context .Background ())
241
- defer cancel ()
242
-
243
- self := peer .ID ("ABC" )
244
- s := NewSwarm (ctx , self , nil , nil )
245
- defer s .Close ()
246
-
247
- // this should fail
248
- _ , err := s .dsync .Dial (ctx , self )
249
- if err != ErrDialToSelf {
250
- t .Fatal ("expected error from self dial" )
251
- }
252
-
253
- // do it twice to make sure we get a new active dial object that fails again
254
- _ , err = s .dsync .Dial (ctx , self )
255
- if err != ErrDialToSelf {
256
- t .Fatal ("expected error from self dial" )
257
- }
258
- }
0 commit comments