Commit f07e2e65 authored by hannahhoward's avatar hannahhoward

test(responsemanager): fix tests

parent 6cece715
...@@ -222,31 +222,33 @@ func TestCancellationQueryInProgress(t *testing.T) { ...@@ -222,31 +222,33 @@ 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
select { // should complete
case sentResponse := <-sentResponses: additionalMessageCount := 0
k := sentResponse.link.(cidlink.Link) drainqueue:
blockIndex := testutil.IndexOf(blks, k.Cid) for {
if blockIndex == -1 { select {
t.Fatal("sent incorrect link") case <-ctx.Done():
} t.Fatal("Should have completed request but didn't")
if !reflect.DeepEqual(sentResponse.data, blks[blockIndex].RawData()) { case sentResponse := <-sentResponses:
t.Fatal("sent incorrect data") if additionalMessageCount > 0 {
} t.Fatal("should not send any more responses")
if sentResponse.requestID != requestID { }
t.Fatal("incorrect response id") k := sentResponse.link.(cidlink.Link)
blockIndex := testutil.IndexOf(blks, k.Cid)
if blockIndex == -1 {
t.Fatal("sent incorrect link")
}
if !reflect.DeepEqual(sentResponse.data, blks[blockIndex].RawData()) {
t.Fatal("sent incorrect data")
}
if sentResponse.requestID != requestID {
t.Fatal("incorrect response id")
}
additionalMessageCount++
case <-requestIDChan:
break drainqueue
} }
case <-ctx.Done():
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:
} }
} }
......
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