swarm/storage/localstore: fix testDB_collectGarbageWorker data race (#19206)

This commit is contained in:
Janoš Guljaš 2019-03-04 22:19:57 +01:00 committed by Viktor Trón
parent a1099bb7e9
commit 216bd2ceba

View File

@ -51,14 +51,16 @@ func testDB_collectGarbageWorker(t *testing.T) {
chunkCount := 150
testHookCollectGarbageChan := make(chan int64)
defer setTestHookCollectGarbage(func(collectedCount int64) {
testHookCollectGarbageChan <- collectedCount
})()
db, cleanupFunc := newTestDB(t, &Options{
Capacity: 100,
})
testHookCollectGarbageChan := make(chan int64)
defer setTestHookCollectGarbage(func(collectedCount int64) {
select {
case testHookCollectGarbageChan <- collectedCount:
case <-db.close:
}
})()
defer cleanupFunc()
uploader := db.NewPutter(ModePutUpload)