@cryptotaxi247 / kubo / commits / 0b9bef1ea

blockstore: fixed data race

Juan Batiz-Benet committed Jan 20, 2015 at 09:27 UTC 0b9bef1ea968acc8c97a4bbf0e185990f4057fe2
1 file changed +6
blocks/blockstore/blockstore_test.go
+6
@@ -118,9 +118,11 @@ func TestAllKeysRespectsContext(t *testing.T) {
118 // Once without context, to make sure it all works
119 {
120 var results dsq.Results
121 + var resultsmu = make(chan struct{})
122 resultChan := make(chan dsq.Result)
123 d.SetFunc(func(q dsq.Query) (dsq.Results, error) {
124 results = dsq.ResultsWithChan(q, resultChan)
125 + resultsmu <- struct{}{}
126 return results, nil
127 })
128
@@ -128,6 +130,7 @@ func TestAllKeysRespectsContext(t *testing.T) {
130
131 // make sure it's waiting.
132 <-started
133 + <-resultsmu
134 select {
135 case <-done:
136 t.Fatal("sync is wrong")
@@ -156,9 +159,11 @@ func TestAllKeysRespectsContext(t *testing.T) {
159 // Once with
160 {
161 var results dsq.Results
162 + var resultsmu = make(chan struct{})
163 resultChan := make(chan dsq.Result)
164 d.SetFunc(func(q dsq.Query) (dsq.Results, error) {
165 results = dsq.ResultsWithChan(q, resultChan)
166 + resultsmu <- struct{}{}
167 return results, nil
168 })
169
@@ -167,6 +172,7 @@ func TestAllKeysRespectsContext(t *testing.T) {
172
173 // make sure it's waiting.
174 <-started
175 + <-resultsmu
176 select {
177 case <-done:
178 t.Fatal("sync is wrong")