Fix race in the TestTopicRelayReuse

This commit is contained in:
Lukasz Zimnoch 2020-05-01 10:30:40 +02:00 committed by vyzo
parent 10f5464279
commit f4f8f3ec12
1 changed files with 13 additions and 2 deletions

View File

@ -619,7 +619,13 @@ func TestTopicRelayReuse(t *testing.T) {
time.Sleep(time.Millisecond * 100)
if pubsubs[0].myRelays[topic] != 3 {
res := make(chan bool, 1)
pubsubs[0].eval <- func() {
res <- pubsubs[0].myRelays[topic] == 3
}
isCorrectNumber := <-res
if !isCorrectNumber {
t.Fatal("incorrect number of relays")
}
@ -629,7 +635,12 @@ func TestTopicRelayReuse(t *testing.T) {
time.Sleep(time.Millisecond * 100)
if pubsubs[0].myRelays[topic] != 0 {
pubsubs[0].eval <- func() {
res <- pubsubs[0].myRelays[topic] == 0
}
isCorrectNumber = <-res
if !isCorrectNumber {
t.Fatal("incorrect number of relays")
}
}