mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm/storage/localstore: fix a race in TestDB_updateGCSem defers
This commit is contained in:
parent
6ad67d7b28
commit
a550388b4d
1 changed files with 13 additions and 14 deletions
|
|
@ -68,19 +68,6 @@ func TestDB(t *testing.T) {
|
||||||
func TestDB_updateGCSem(t *testing.T) {
|
func TestDB_updateGCSem(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
defer func(m int) { maxParallelUpdateGC = m }(maxParallelUpdateGC)
|
|
||||||
maxParallelUpdateGC = 3
|
|
||||||
|
|
||||||
db, cleanupFunc := newTestDB(t, nil)
|
|
||||||
defer cleanupFunc()
|
|
||||||
|
|
||||||
chunk := generateRandomChunk()
|
|
||||||
|
|
||||||
err := db.NewPutter(ModePutUpload).Put(chunk)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateGCSleep := time.Second
|
updateGCSleep := time.Second
|
||||||
var count int
|
var count int
|
||||||
var max int
|
var max int
|
||||||
|
|
@ -103,6 +90,19 @@ func TestDB_updateGCSem(t *testing.T) {
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
defer func(m int) { maxParallelUpdateGC = m }(maxParallelUpdateGC)
|
||||||
|
maxParallelUpdateGC = 3
|
||||||
|
|
||||||
|
db, cleanupFunc := newTestDB(t, nil)
|
||||||
|
defer cleanupFunc()
|
||||||
|
|
||||||
|
chunk := generateRandomChunk()
|
||||||
|
|
||||||
|
err := db.NewPutter(ModePutUpload).Put(chunk)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
getter := db.NewGetter(ModeGetRequest)
|
getter := db.NewGetter(ModeGetRequest)
|
||||||
|
|
||||||
// get more chunks then maxParallelUpdateGC
|
// get more chunks then maxParallelUpdateGC
|
||||||
|
|
@ -117,7 +117,6 @@ func TestDB_updateGCSem(t *testing.T) {
|
||||||
if max != maxParallelUpdateGC {
|
if max != maxParallelUpdateGC {
|
||||||
t.Errorf("got max %v, want %v", max, maxParallelUpdateGC)
|
t.Errorf("got max %v, want %v", max, maxParallelUpdateGC)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BenchmarkNew measures the time that New function
|
// BenchmarkNew measures the time that New function
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue