mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/storage/localstore: fix TestDB_collectGarbageWorker_withRequests
This commit is contained in:
parent
8af07768dd
commit
62d79bfbf0
1 changed files with 19 additions and 0 deletions
|
|
@ -156,6 +156,14 @@ func TestDB_collectGarbageWorker_withRequests(t *testing.T) {
|
||||||
addrs = append(addrs, chunk.Address())
|
addrs = append(addrs, chunk.Address())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set update gc test hook to signal when
|
||||||
|
// update gc goroutine is done by closing
|
||||||
|
// testHookUpdateGCChan channel
|
||||||
|
testHookUpdateGCChan := make(chan struct{})
|
||||||
|
resetTestHookUpdateGC := setTestHookUpdateGC(func() {
|
||||||
|
close(testHookUpdateGCChan)
|
||||||
|
})
|
||||||
|
|
||||||
// request the latest synced chunk
|
// request the latest synced chunk
|
||||||
// to prioritize it in the gc index
|
// to prioritize it in the gc index
|
||||||
// not to be collected
|
// not to be collected
|
||||||
|
|
@ -164,6 +172,17 @@ func TestDB_collectGarbageWorker_withRequests(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wait for update gc goroutine to finish for garbage
|
||||||
|
// collector to be correctly triggered after the last upload
|
||||||
|
select {
|
||||||
|
case <-testHookUpdateGCChan:
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
t.Fatal("updateGC was not called after getting chunk with ModeGetRequest")
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need to wait for update gc hook anymore
|
||||||
|
resetTestHookUpdateGC()
|
||||||
|
|
||||||
// upload and sync another chunk to trigger
|
// upload and sync another chunk to trigger
|
||||||
// garbage collection
|
// garbage collection
|
||||||
ch := generateTestRandomChunk()
|
ch := generateTestRandomChunk()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue