@@ -37,27 +37,9 @@ import (
3737 "github.com/davecgh/go-spew/spew"
3838)
3939
40- // This test checks calling a method that returns 'null'.
41- func TestClientNullResponse (t * testing.T ) {
42- server := newTestServer ()
43- defer server .Stop ()
44-
45- client := DialInProc (server )
46- defer client .Close ()
47-
48- var result json.RawMessage
49- if err := client .Call (& result , "test_null" ); err != nil {
50- t .Fatal (err )
51- }
52- if result == nil {
53- t .Fatal ("Expected non-nil result" )
54- }
55- if ! reflect .DeepEqual (result , json .RawMessage ("null" )) {
56- t .Errorf ("Expected null, got %s" , result )
57- }
58- }
59-
6040func TestClientRequest (t * testing.T ) {
41+ t .Parallel ()
42+
6143 server := newTestServer ()
6244 defer server .Stop ()
6345 client := DialInProc (server )
@@ -73,6 +55,8 @@ func TestClientRequest(t *testing.T) {
7355}
7456
7557func TestClientResponseType (t * testing.T ) {
58+ t .Parallel ()
59+
7660 server := newTestServer ()
7761 defer server .Stop ()
7862 client := DialInProc (server )
@@ -89,8 +73,32 @@ func TestClientResponseType(t *testing.T) {
8973 }
9074}
9175
76+ // This test checks calling a method that returns 'null'.
77+ func TestClientNullResponse (t * testing.T ) {
78+ t .Parallel ()
79+
80+ server := newTestServer ()
81+ defer server .Stop ()
82+
83+ client := DialInProc (server )
84+ defer client .Close ()
85+
86+ var result json.RawMessage
87+ if err := client .Call (& result , "test_null" ); err != nil {
88+ t .Fatal (err )
89+ }
90+ if result == nil {
91+ t .Fatal ("Expected non-nil result" )
92+ }
93+ if ! reflect .DeepEqual (result , json .RawMessage ("null" )) {
94+ t .Errorf ("Expected null, got %s" , result )
95+ }
96+ }
97+
9298// This test checks that server-returned errors with code and data come out of Client.Call.
9399func TestClientErrorData (t * testing.T ) {
100+ t .Parallel ()
101+
94102 server := newTestServer ()
95103 defer server .Stop ()
96104 client := DialInProc (server )
@@ -121,6 +129,8 @@ func TestClientErrorData(t *testing.T) {
121129}
122130
123131func TestClientBatchRequest (t * testing.T ) {
132+ t .Parallel ()
133+
124134 server := newTestServer ()
125135 defer server .Stop ()
126136 client := DialInProc (server )
@@ -172,6 +182,8 @@ func TestClientBatchRequest(t *testing.T) {
172182// This checks that, for HTTP connections, the length of batch responses is validated to
173183// match the request exactly.
174184func TestClientBatchRequest_len (t * testing.T ) {
185+ t .Parallel ()
186+
175187 b , err := json .Marshal ([]jsonrpcMessage {
176188 {Version : "2.0" , ID : json .RawMessage ("1" ), Result : json .RawMessage (`"0x1"` )},
177189 {Version : "2.0" , ID : json .RawMessage ("2" ), Result : json .RawMessage (`"0x2"` )},
@@ -188,6 +200,8 @@ func TestClientBatchRequest_len(t *testing.T) {
188200 t .Cleanup (s .Close )
189201
190202 t .Run ("too-few" , func (t * testing.T ) {
203+ t .Parallel ()
204+
191205 client , err := Dial (s .URL )
192206 if err != nil {
193207 t .Fatal ("failed to dial test server:" , err )
@@ -218,6 +232,8 @@ func TestClientBatchRequest_len(t *testing.T) {
218232 })
219233
220234 t .Run ("too-many" , func (t * testing.T ) {
235+ t .Parallel ()
236+
221237 client , err := Dial (s .URL )
222238 if err != nil {
223239 t .Fatal ("failed to dial test server:" , err )
@@ -249,6 +265,8 @@ func TestClientBatchRequest_len(t *testing.T) {
249265// This checks that the client can handle the case where the server doesn't
250266// respond to all requests in a batch.
251267func TestClientBatchRequestLimit (t * testing.T ) {
268+ t .Parallel ()
269+
252270 server := newTestServer ()
253271 defer server .Stop ()
254272 server .SetBatchLimits (2 , 100000 )
@@ -285,6 +303,8 @@ func TestClientBatchRequestLimit(t *testing.T) {
285303}
286304
287305func TestClientNotify (t * testing.T ) {
306+ t .Parallel ()
307+
288308 server := newTestServer ()
289309 defer server .Stop ()
290310 client := DialInProc (server )
@@ -392,6 +412,8 @@ func testClientCancel(transport string, t *testing.T) {
392412}
393413
394414func TestClientSubscribeInvalidArg (t * testing.T ) {
415+ t .Parallel ()
416+
395417 server := newTestServer ()
396418 defer server .Stop ()
397419 client := DialInProc (server )
@@ -422,6 +444,8 @@ func TestClientSubscribeInvalidArg(t *testing.T) {
422444}
423445
424446func TestClientSubscribe (t * testing.T ) {
447+ t .Parallel ()
448+
425449 server := newTestServer ()
426450 defer server .Stop ()
427451 client := DialInProc (server )
@@ -454,6 +478,8 @@ func TestClientSubscribe(t *testing.T) {
454478
455479// In this test, the connection drops while Subscribe is waiting for a response.
456480func TestClientSubscribeClose (t * testing.T ) {
481+ t .Parallel ()
482+
457483 server := newTestServer ()
458484 service := & notificationTestService {
459485 gotHangSubscriptionReq : make (chan struct {}),
@@ -498,6 +524,8 @@ func TestClientSubscribeClose(t *testing.T) {
498524// This test reproduces https://github.com/ethereum/go-ethereum/issues/17837 where the
499525// client hangs during shutdown when Unsubscribe races with Client.Close.
500526func TestClientCloseUnsubscribeRace (t * testing.T ) {
527+ t .Parallel ()
528+
501529 server := newTestServer ()
502530 defer server .Stop ()
503531
@@ -540,6 +568,8 @@ func (b *unsubscribeBlocker) readBatch() ([]*jsonrpcMessage, bool, error) {
540568// not respond.
541569// It reproducers the issue https://github.com/ethereum/go-ethereum/issues/30156
542570func TestUnsubscribeTimeout (t * testing.T ) {
571+ t .Parallel ()
572+
543573 srv := NewServer ()
544574 srv .RegisterName ("nftest" , new (notificationTestService ))
545575
@@ -674,6 +704,8 @@ func TestClientSubscriptionChannelClose(t *testing.T) {
674704// This test checks that Client doesn't lock up when a single subscriber
675705// doesn't read subscription events.
676706func TestClientNotificationStorm (t * testing.T ) {
707+ t .Parallel ()
708+
677709 server := newTestServer ()
678710 defer server .Stop ()
679711
@@ -726,6 +758,8 @@ func TestClientNotificationStorm(t *testing.T) {
726758}
727759
728760func TestClientSetHeader (t * testing.T ) {
761+ t .Parallel ()
762+
729763 var gotHeader bool
730764 srv := newTestServer ()
731765 httpsrv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -762,6 +796,8 @@ func TestClientSetHeader(t *testing.T) {
762796}
763797
764798func TestClientHTTP (t * testing.T ) {
799+ t .Parallel ()
800+
765801 server := newTestServer ()
766802 defer server .Stop ()
767803
@@ -804,6 +840,8 @@ func TestClientHTTP(t *testing.T) {
804840}
805841
806842func TestClientReconnect (t * testing.T ) {
843+ t .Parallel ()
844+
807845 startServer := func (addr string ) (* Server , net.Listener ) {
808846 srv := newTestServer ()
809847 l , err := net .Listen ("tcp" , addr )
0 commit comments