mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
exchange/websocket: Fix TestMatchReturnResponses race condition causing index out of range panic (#2079)
* Initial plan * Fix TestMatchReturnResponses race condition panic Co-authored-by: thrasher- <4685270+thrasher-@users.noreply.github.com> * Add require.NotEmpty check on resp.Responses to prevent panic Co-authored-by: shazbert <9391715+shazbert@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thrasher- <4685270+thrasher-@users.noreply.github.com> Co-authored-by: shazbert <9391715+shazbert@users.noreply.github.com>
This commit is contained in:
@@ -19,14 +19,17 @@ func TestMatchReturnResponses(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
require.ErrorIs(t, (<-ch).Err, ErrSignatureTimeout)
|
||||
conn.ResponseMaxLimit = time.Millisecond
|
||||
conn.ResponseMaxLimit = time.Second
|
||||
|
||||
ch, err = conn.MatchReturnResponses(t.Context(), nil, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
exp := []byte("test")
|
||||
require.True(t, conn.Match.IncomingWithData(nil, exp))
|
||||
assert.Equal(t, exp, (<-ch).Responses[0])
|
||||
resp := <-ch
|
||||
require.NoError(t, resp.Err)
|
||||
require.NotEmpty(t, resp.Responses, "must have response data")
|
||||
assert.Equal(t, exp, resp.Responses[0])
|
||||
}
|
||||
|
||||
func TestWebsocketConnectionRequireMatchWithData(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user