mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm/storage/localstore: protect chunks in TestModePutUpload_parallel
This commit is contained in:
parent
87bbd617bd
commit
6ad67d7b28
1 changed files with 7 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ package localstore
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -158,6 +159,7 @@ func TestModePutUpload_parallel(t *testing.T) {
|
|||
}
|
||||
|
||||
chunks := make([]storage.Chunk, 0)
|
||||
var chunksMu sync.Mutex
|
||||
|
||||
// send chunks to workers
|
||||
go func() {
|
||||
|
|
@ -168,7 +170,9 @@ func TestModePutUpload_parallel(t *testing.T) {
|
|||
case <-doneChan:
|
||||
return
|
||||
}
|
||||
chunksMu.Lock()
|
||||
chunks = append(chunks, chunk)
|
||||
chunksMu.Unlock()
|
||||
}
|
||||
|
||||
close(chunkChan)
|
||||
|
|
@ -184,6 +188,9 @@ func TestModePutUpload_parallel(t *testing.T) {
|
|||
|
||||
// get every chunk and validate its data
|
||||
getter := db.NewGetter(ModeGetRequest)
|
||||
|
||||
chunksMu.Lock()
|
||||
defer chunksMu.Unlock()
|
||||
for _, chunk := range chunks {
|
||||
got, err := getter.Get(chunk.Address())
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue