From fe5b5702f953273b1e91b23960e15e2ac6e38d76 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 20 Jan 2021 14:43:19 -0800 Subject: [PATCH] fix data race in test --- chain/sync_manager_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chain/sync_manager_test.go b/chain/sync_manager_test.go index a5ff033ac..5f23e67c0 100644 --- a/chain/sync_manager_test.go +++ b/chain/sync_manager_test.go @@ -150,8 +150,11 @@ func TestSyncManagerEdgeCase(t *testing.T) { t.Fatalf("Expected tipset %s to sync, but got %s", e1, last) } - if len(sm.state) != 0 { - t.Errorf("active syncs expected empty but got: %d", len(sm.state)) + sm.mx.Lock() + activeSyncs := len(sm.state) + sm.mx.Unlock() + if activeSyncs != 0 { + t.Errorf("active syncs expected empty but got: %d", activeSyncs) } }) }