Skip to content

Commit

Permalink
Fix race condition found in TestRejoinOnReconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada committed Sep 12, 2021
1 parent cb9ca8d commit a45147b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ func TestRejoinOnReconnect(t *testing.T) {

client.Join("gempiR")

go client.Connect()
clientDisconnected := connectAndEnsureGoodDisconnect(t, client)

// wait for server to receive message
select {
Expand All @@ -2010,10 +2010,13 @@ func TestRejoinOnReconnect(t *testing.T) {
// Manually disconnect
client.Disconnect()

<-clientDisconnected

waitEnd = make(chan struct{})

// Manually reconnect
go client.Connect()

waitEnd = make(chan struct{})
select {
case <-waitEnd:
case <-time.After(time.Second * 3):
Expand Down

0 comments on commit a45147b

Please sign in to comment.