mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 07:57:30 +08:00
Merge pull request #2857 from ipfs/feature/test-race-blockstore
Remove failing blockstore with context test
This commit is contained in:
@ -117,8 +117,6 @@ func TestAllKeysRespectsContext(t *testing.T) {
|
|||||||
errors <- nil // a nil one to signal break
|
errors <- nil // a nil one to signal break
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once without context, to make sure it all works
|
|
||||||
{
|
|
||||||
var results dsq.Results
|
var results dsq.Results
|
||||||
var resultsmu = make(chan struct{})
|
var resultsmu = make(chan struct{})
|
||||||
resultChan := make(chan dsq.Result)
|
resultChan := make(chan dsq.Result)
|
||||||
@ -156,59 +154,6 @@ func TestAllKeysRespectsContext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Once with
|
|
||||||
{
|
|
||||||
var results dsq.Results
|
|
||||||
var resultsmu = make(chan struct{})
|
|
||||||
resultChan := make(chan dsq.Result)
|
|
||||||
d.SetFunc(func(q dsq.Query) (dsq.Results, error) {
|
|
||||||
results = dsq.ResultsWithChan(q, resultChan)
|
|
||||||
resultsmu <- struct{}{}
|
|
||||||
return results, nil
|
|
||||||
})
|
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
go getKeys(ctx)
|
|
||||||
|
|
||||||
// make sure it's waiting.
|
|
||||||
<-started
|
|
||||||
<-resultsmu
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
t.Fatal("sync is wrong")
|
|
||||||
case <-results.Process().Closing():
|
|
||||||
t.Fatal("should not be closing")
|
|
||||||
case <-results.Process().Closed():
|
|
||||||
t.Fatal("should not be closed")
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel() // let it go.
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
t.Fatal("sync is wrong")
|
|
||||||
case <-results.Process().Closed():
|
|
||||||
t.Fatal("should not be closed") // should not be closed yet.
|
|
||||||
case <-results.Process().Closing():
|
|
||||||
// should be closing now!
|
|
||||||
t.Log("closing correctly at this point.")
|
|
||||||
}
|
|
||||||
|
|
||||||
close(resultChan)
|
|
||||||
<-done // should be done now.
|
|
||||||
<-results.Process().Closed() // should be closed now
|
|
||||||
|
|
||||||
// print any errors
|
|
||||||
for err := range errors {
|
|
||||||
if err == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user