From 208037b590e51ff29d38be9a5d595510c3bd4d76 Mon Sep 17 00:00:00 2001 From: gammazero Date: Fri, 22 Dec 2023 01:22:27 -0800 Subject: [PATCH] Fix possible concurrent map write in test --- dagsync/subscriber_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dagsync/subscriber_test.go b/dagsync/subscriber_test.go index 623c531..28db72c 100644 --- a/dagsync/subscriber_test.go +++ b/dagsync/subscriber_test.go @@ -617,8 +617,11 @@ func TestMaxAsyncSyncs(t *testing.T) { dstHost := test.MkTestHost(t) dstLnkS, blocked := test.MkBlockedLinkSystem(dstStore) blocksSeenByHook := make(map[cid.Cid]struct{}) + bhMutex := new(sync.Mutex) blockHook := func(p peer.ID, c cid.Cid, _ dagsync.SegmentSyncActions) { + bhMutex.Lock() blocksSeenByHook[c] = struct{}{} + bhMutex.Unlock() } sub, err := dagsync.NewSubscriber(dstHost, dstStore, dstLnkS, testTopic,