From 95071e955a30ccd3a48e7303adad82506727b846 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 30 Apr 2019 10:49:02 +0300 Subject: [PATCH] pacify the race detector in TestGossipsubFanoutExpiry --- gossipsub_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gossipsub_test.go b/gossipsub_test.go index 82db855..f85c908 100644 --- a/gossipsub_test.go +++ b/gossipsub_test.go @@ -297,16 +297,23 @@ func TestGossipsubFanoutExpiry(t *testing.T) { } } - if len(psubs[0].rt.(*GossipSubRouter).fanout) == 0 { - t.Fatal("owner has no fanout") + psubs[0].eval <- func() { + if len(psubs[0].rt.(*GossipSubRouter).fanout) == 0 { + t.Fatal("owner has no fanout") + } } // wait for TTL to expire fanout peers in owner time.Sleep(time.Second * 2) - if len(psubs[0].rt.(*GossipSubRouter).fanout) > 0 { - t.Fatal("fanout hasn't expired") + psubs[0].eval <- func() { + if len(psubs[0].rt.(*GossipSubRouter).fanout) > 0 { + t.Fatal("fanout hasn't expired") + } } + + // wait for it to run in the event loop + time.Sleep(10 * time.Millisecond) } func TestGossipsubGossip(t *testing.T) {