@@ -37,27 +37,9 @@ import (
37
37
"github.com/davecgh/go-spew/spew"
38
38
)
39
39
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
-
60
40
func TestClientRequest (t * testing.T ) {
41
+ t .Parallel ()
42
+
61
43
server := newTestServer ()
62
44
defer server .Stop ()
63
45
client := DialInProc (server )
@@ -73,6 +55,8 @@ func TestClientRequest(t *testing.T) {
73
55
}
74
56
75
57
func TestClientResponseType (t * testing.T ) {
58
+ t .Parallel ()
59
+
76
60
server := newTestServer ()
77
61
defer server .Stop ()
78
62
client := DialInProc (server )
@@ -89,8 +73,32 @@ func TestClientResponseType(t *testing.T) {
89
73
}
90
74
}
91
75
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
+
92
98
// This test checks that server-returned errors with code and data come out of Client.Call.
93
99
func TestClientErrorData (t * testing.T ) {
100
+ t .Parallel ()
101
+
94
102
server := newTestServer ()
95
103
defer server .Stop ()
96
104
client := DialInProc (server )
@@ -121,6 +129,8 @@ func TestClientErrorData(t *testing.T) {
121
129
}
122
130
123
131
func TestClientBatchRequest (t * testing.T ) {
132
+ t .Parallel ()
133
+
124
134
server := newTestServer ()
125
135
defer server .Stop ()
126
136
client := DialInProc (server )
@@ -172,6 +182,8 @@ func TestClientBatchRequest(t *testing.T) {
172
182
// This checks that, for HTTP connections, the length of batch responses is validated to
173
183
// match the request exactly.
174
184
func TestClientBatchRequest_len (t * testing.T ) {
185
+ t .Parallel ()
186
+
175
187
b , err := json .Marshal ([]jsonrpcMessage {
176
188
{Version : "2.0" , ID : json .RawMessage ("1" ), Result : json .RawMessage (`"0x1"` )},
177
189
{Version : "2.0" , ID : json .RawMessage ("2" ), Result : json .RawMessage (`"0x2"` )},
@@ -188,6 +200,8 @@ func TestClientBatchRequest_len(t *testing.T) {
188
200
t .Cleanup (s .Close )
189
201
190
202
t .Run ("too-few" , func (t * testing.T ) {
203
+ t .Parallel ()
204
+
191
205
client , err := Dial (s .URL )
192
206
if err != nil {
193
207
t .Fatal ("failed to dial test server:" , err )
@@ -218,6 +232,8 @@ func TestClientBatchRequest_len(t *testing.T) {
218
232
})
219
233
220
234
t .Run ("too-many" , func (t * testing.T ) {
235
+ t .Parallel ()
236
+
221
237
client , err := Dial (s .URL )
222
238
if err != nil {
223
239
t .Fatal ("failed to dial test server:" , err )
@@ -249,6 +265,8 @@ func TestClientBatchRequest_len(t *testing.T) {
249
265
// This checks that the client can handle the case where the server doesn't
250
266
// respond to all requests in a batch.
251
267
func TestClientBatchRequestLimit (t * testing.T ) {
268
+ t .Parallel ()
269
+
252
270
server := newTestServer ()
253
271
defer server .Stop ()
254
272
server .SetBatchLimits (2 , 100000 )
@@ -285,6 +303,8 @@ func TestClientBatchRequestLimit(t *testing.T) {
285
303
}
286
304
287
305
func TestClientNotify (t * testing.T ) {
306
+ t .Parallel ()
307
+
288
308
server := newTestServer ()
289
309
defer server .Stop ()
290
310
client := DialInProc (server )
@@ -392,6 +412,8 @@ func testClientCancel(transport string, t *testing.T) {
392
412
}
393
413
394
414
func TestClientSubscribeInvalidArg (t * testing.T ) {
415
+ t .Parallel ()
416
+
395
417
server := newTestServer ()
396
418
defer server .Stop ()
397
419
client := DialInProc (server )
@@ -422,6 +444,8 @@ func TestClientSubscribeInvalidArg(t *testing.T) {
422
444
}
423
445
424
446
func TestClientSubscribe (t * testing.T ) {
447
+ t .Parallel ()
448
+
425
449
server := newTestServer ()
426
450
defer server .Stop ()
427
451
client := DialInProc (server )
@@ -454,6 +478,8 @@ func TestClientSubscribe(t *testing.T) {
454
478
455
479
// In this test, the connection drops while Subscribe is waiting for a response.
456
480
func TestClientSubscribeClose (t * testing.T ) {
481
+ t .Parallel ()
482
+
457
483
server := newTestServer ()
458
484
service := & notificationTestService {
459
485
gotHangSubscriptionReq : make (chan struct {}),
@@ -498,6 +524,8 @@ func TestClientSubscribeClose(t *testing.T) {
498
524
// This test reproduces https://github.com/ethereum/go-ethereum/issues/17837 where the
499
525
// client hangs during shutdown when Unsubscribe races with Client.Close.
500
526
func TestClientCloseUnsubscribeRace (t * testing.T ) {
527
+ t .Parallel ()
528
+
501
529
server := newTestServer ()
502
530
defer server .Stop ()
503
531
@@ -540,6 +568,8 @@ func (b *unsubscribeBlocker) readBatch() ([]*jsonrpcMessage, bool, error) {
540
568
// not respond.
541
569
// It reproducers the issue https://github.com/ethereum/go-ethereum/issues/30156
542
570
func TestUnsubscribeTimeout (t * testing.T ) {
571
+ t .Parallel ()
572
+
543
573
srv := NewServer ()
544
574
srv .RegisterName ("nftest" , new (notificationTestService ))
545
575
@@ -674,6 +704,8 @@ func TestClientSubscriptionChannelClose(t *testing.T) {
674
704
// This test checks that Client doesn't lock up when a single subscriber
675
705
// doesn't read subscription events.
676
706
func TestClientNotificationStorm (t * testing.T ) {
707
+ t .Parallel ()
708
+
677
709
server := newTestServer ()
678
710
defer server .Stop ()
679
711
@@ -726,6 +758,8 @@ func TestClientNotificationStorm(t *testing.T) {
726
758
}
727
759
728
760
func TestClientSetHeader (t * testing.T ) {
761
+ t .Parallel ()
762
+
729
763
var gotHeader bool
730
764
srv := newTestServer ()
731
765
httpsrv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -762,6 +796,8 @@ func TestClientSetHeader(t *testing.T) {
762
796
}
763
797
764
798
func TestClientHTTP (t * testing.T ) {
799
+ t .Parallel ()
800
+
765
801
server := newTestServer ()
766
802
defer server .Stop ()
767
803
@@ -804,6 +840,8 @@ func TestClientHTTP(t *testing.T) {
804
840
}
805
841
806
842
func TestClientReconnect (t * testing.T ) {
843
+ t .Parallel ()
844
+
807
845
startServer := func (addr string ) (* Server , net.Listener ) {
808
846
srv := newTestServer ()
809
847
l , err := net .Listen ("tcp" , addr )
0 commit comments