Commit f07e2e65 authored by hannahhoward's avatar hannahhoward

test(responsemanager): fix tests

parent 6cece715
...@@ -222,9 +222,18 @@ func TestCancellationQueryInProgress(t *testing.T) { ...@@ -222,9 +222,18 @@ func TestCancellationQueryInProgress(t *testing.T) {
responseManager.synchronize() responseManager.synchronize()
// read one block -- to unblock processing // at this point we should receive at most one more block, then traversal
// should complete
additionalMessageCount := 0
drainqueue:
for {
select { select {
case <-ctx.Done():
t.Fatal("Should have completed request but didn't")
case sentResponse := <-sentResponses: case sentResponse := <-sentResponses:
if additionalMessageCount > 0 {
t.Fatal("should not send any more responses")
}
k := sentResponse.link.(cidlink.Link) k := sentResponse.link.(cidlink.Link)
blockIndex := testutil.IndexOf(blks, k.Cid) blockIndex := testutil.IndexOf(blks, k.Cid)
if blockIndex == -1 { if blockIndex == -1 {
...@@ -236,17 +245,10 @@ func TestCancellationQueryInProgress(t *testing.T) { ...@@ -236,17 +245,10 @@ func TestCancellationQueryInProgress(t *testing.T) {
if sentResponse.requestID != requestID { if sentResponse.requestID != requestID {
t.Fatal("incorrect response id") t.Fatal("incorrect response id")
} }
case <-ctx.Done(): additionalMessageCount++
t.Fatal("did not send responses")
}
// at this point traversal should abort and we should receive a completion
select {
case <-ctx.Done():
t.Fatal("Should have completed request but didn't")
case <-sentResponses:
t.Fatal("should not send any more responses")
case <-requestIDChan: case <-requestIDChan:
break drainqueue
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment