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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -158,6 +159,7 @@ func TestModePutUpload_parallel(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chunks := make([]storage.Chunk, 0)
|
chunks := make([]storage.Chunk, 0)
|
||||||
|
var chunksMu sync.Mutex
|
||||||
|
|
||||||
// send chunks to workers
|
// send chunks to workers
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -168,7 +170,9 @@ func TestModePutUpload_parallel(t *testing.T) {
|
||||||
case <-doneChan:
|
case <-doneChan:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
chunksMu.Lock()
|
||||||
chunks = append(chunks, chunk)
|
chunks = append(chunks, chunk)
|
||||||
|
chunksMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
close(chunkChan)
|
close(chunkChan)
|
||||||
|
|
@ -184,6 +188,9 @@ func TestModePutUpload_parallel(t *testing.T) {
|
||||||
|
|
||||||
// get every chunk and validate its data
|
// get every chunk and validate its data
|
||||||
getter := db.NewGetter(ModeGetRequest)
|
getter := db.NewGetter(ModeGetRequest)
|
||||||
|
|
||||||
|
chunksMu.Lock()
|
||||||
|
defer chunksMu.Unlock()
|
||||||
for _, chunk := range chunks {
|
for _, chunk := range chunks {
|
||||||
got, err := getter.Get(chunk.Address())
|
got, err := getter.Get(chunk.Address())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue