From be56353a0e362038c6dcf8912395d797c1685ccf Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Wed, 16 Jan 2019 16:33:54 +0100 Subject: [PATCH] swarm/storage: fix data races in TestLDBStoreCollectGarbage --- swarm/storage/ldbstore_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swarm/storage/ldbstore_test.go b/swarm/storage/ldbstore_test.go index 1fe466f930..e8ff9c444b 100644 --- a/swarm/storage/ldbstore_test.go +++ b/swarm/storage/ldbstore_test.go @@ -388,7 +388,9 @@ func testLDBStoreCollectGarbage(t *testing.T) { t.Fatal(err.Error()) } allChunks = append(allChunks, chunks...) + ldb.lock.Lock() log.Debug("ldbstore", "entrycnt", ldb.entryCnt, "accesscnt", ldb.accessCnt, "cap", capacity, "n", n) + ldb.lock.Unlock() ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() @@ -537,7 +539,9 @@ func testLDBStoreRemoveThenCollectGarbage(t *testing.T) { remaining -= putCount for putCount > 0 { ldb.Put(context.TODO(), chunks[puts]) + ldb.lock.Lock() log.Debug("ldbstore", "entrycnt", ldb.entryCnt, "accesscnt", ldb.accessCnt, "cap", capacity, "n", n, "puts", puts, "remaining", remaining, "roundtarget", roundTarget) + ldb.lock.Unlock() puts++ putCount-- }