network: fix discoverer test
Asynchronous tryAddress() routines may get dial result AFTER the switch to another test, so we need to ensure that they'll get the result intended for this particular call. Fixes: 2021-07-07T20:25:40.1624521Z === RUN TestDefaultDiscoverer 2021-07-07T20:25:40.1625316Z discovery_test.go:159: timeout expecting for transport dial; i: 2, j: 1 2021-07-07T20:25:40.1626319Z --- FAIL: TestDefaultDiscoverer (1.19s)
This commit is contained in:
parent
bd400dfe20
commit
9cc4f42a71
1 changed files with 5 additions and 4 deletions
|
@ -27,12 +27,13 @@ func newFakeTransp(s *Server) Transporter {
|
|||
}
|
||||
|
||||
func (ft *fakeTransp) Dial(addr string, timeout time.Duration) error {
|
||||
var ret error
|
||||
if atomic.LoadInt32(&ft.retFalse) > 0 {
|
||||
ret = errors.New("smth bad happened")
|
||||
}
|
||||
ft.dialCh <- addr
|
||||
|
||||
if atomic.LoadInt32(&ft.retFalse) > 0 {
|
||||
return errors.New("smth bad happened")
|
||||
}
|
||||
return nil
|
||||
return ret
|
||||
}
|
||||
func (ft *fakeTransp) Accept() {
|
||||
if ft.started.Load() {
|
||||
|
|
Loading…
Reference in a new issue