swarm/storage: add sleep to wait for gc

This commit is contained in:
Anton Evangelatov 2018-04-13 15:32:16 +03:00
parent ce3d732c4a
commit 51387aaea0

View file

@ -23,6 +23,7 @@ import (
"os" "os"
"sync" "sync"
"testing" "testing"
"time"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -340,7 +341,7 @@ func TestLDBStoreCollectGarbage(t *testing.T) {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
c := NewRandomChunk(chunkSize) c := NewRandomChunk(chunkSize)
chunks = append(chunks, c) chunks = append(chunks, c)
log.Info("generate random chunk", "idx", i, "chunk", c) log.Trace("generate random chunk", "idx", i, "chunk", c)
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
@ -354,6 +355,9 @@ func TestLDBStoreCollectGarbage(t *testing.T) {
log.Info("ldbstore", "entrycnt", ldb.entryCnt, "accesscnt", ldb.accessCnt) log.Info("ldbstore", "entrycnt", ldb.entryCnt, "accesscnt", ldb.accessCnt)
// wait for garbage collection to kick in on the responsible actor
time.Sleep(5 * time.Second)
var missing int var missing int
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
ret, err := ldb.Get(chunks[i].Key) ret, err := ldb.Get(chunks[i].Key)
@ -369,7 +373,7 @@ func TestLDBStoreCollectGarbage(t *testing.T) {
t.Fatal("expected to get the same data back, but got smth else") t.Fatal("expected to get the same data back, but got smth else")
} }
log.Info("got back chunk", "chunk", ret) log.Trace("got back chunk", "chunk", ret)
} }
if missing < n-capacity { if missing < n-capacity {