Skip to content

Commit 6bf05ac

Browse files
author
Mak Muftic
committed
Revert test fixes
1 parent 969e90e commit 6bf05ac

File tree

3 files changed

+37
-41
lines changed

3 files changed

+37
-41
lines changed

gethrpc/client_test.go

+34-37
Original file line numberDiff line numberDiff line change
@@ -203,36 +203,36 @@ func testClientCancel(transport string, t *testing.T) {
203203
wg.Wait()
204204
}
205205

206-
//func TestClientSubscribeInvalidArg(t *testing.T) {
207-
// server := newTestServer()
208-
// defer server.Stop()
209-
// client := DialInProc(server)
210-
// defer client.Close()
211-
//
212-
// check := func(shouldPanic bool, arg interface{}) {
213-
// defer func() {
214-
// err := recover()
215-
// if shouldPanic && err == nil {
216-
// t.Errorf("EthSubscribe should've panicked for %#v", arg)
217-
// }
218-
// if !shouldPanic && err != nil {
219-
// t.Errorf("EthSubscribe shouldn't have panicked for %#v", arg)
220-
// buf := make([]byte, 1024*1024)
221-
// buf = buf[:runtime.Stack(buf, false)]
222-
// t.Error(err)
223-
// t.Error(string(buf))
224-
// }
225-
// }()
226-
// // todo
227-
// // client.EthSubscribe(context.Background(), arg, "foo_bar")
228-
// }
229-
// check(true, nil)
230-
// check(true, 1)
231-
// check(true, (chan int)(nil))
232-
// check(true, make(<-chan int))
233-
// check(false, make(chan int))
234-
// check(false, make(chan<- int))
235-
//}
206+
func TestClientSubscribeInvalidArg(t *testing.T) {
207+
server := newTestServer()
208+
defer server.Stop()
209+
client := DialInProc(server)
210+
defer client.Close()
211+
212+
check := func(shouldPanic bool, arg interface{}) {
213+
defer func() {
214+
err := recover()
215+
if shouldPanic && err == nil {
216+
t.Errorf("EthSubscribe should've panicked for %#v", arg)
217+
}
218+
if !shouldPanic && err != nil {
219+
t.Errorf("EthSubscribe shouldn't have panicked for %#v", arg)
220+
buf := make([]byte, 1024*1024)
221+
buf = buf[:runtime.Stack(buf, false)]
222+
t.Error(err)
223+
t.Error(string(buf))
224+
}
225+
}()
226+
// todo
227+
client.EthSubscribe(context.Background(), arg, "foo_bar")
228+
}
229+
check(true, nil)
230+
check(true, 1)
231+
check(true, (chan int)(nil))
232+
check(true, make(<-chan int))
233+
check(false, make(chan int))
234+
check(false, make(chan<- int))
235+
}
236236

237237
func TestClientSubscribe(t *testing.T) {
238238
server := newTestServer()
@@ -242,7 +242,7 @@ func TestClientSubscribe(t *testing.T) {
242242

243243
nc := make(chan int)
244244
count := 10
245-
sub, err := client.Subscribe(context.Background(), "nftest","someSubscription", "", "", nc, count, 0)
245+
sub, err := client.Subscribe(context.Background(), "nftest", nc, "someSubscription", count, 0)
246246

247247
if err != nil {
248248
t.Fatal("can't subscribe:", err)
@@ -288,8 +288,7 @@ func TestClientSubscribeClose(t *testing.T) {
288288
err error
289289
)
290290
go func() {
291-
// todo
292-
sub, err = client.Subscribe(context.Background(), "nftest2", "hangSubscription", "hangSubscription", "hangSubscription", nc)
291+
sub, err = client.Subscribe(context.Background(), "nftest2", nc, "hangSubscription", 999)
293292
errc <- err
294293
}()
295294

@@ -319,8 +318,7 @@ func TestClientCloseUnsubscribeRace(t *testing.T) {
319318
for i := 0; i < 20; i++ {
320319
client := DialInProc(server)
321320
nc := make(chan int)
322-
// todo
323-
sub, err := client.Subscribe(context.Background(), "nftest", "someSubscription", "someSubscription", "someSubscription", nc)
321+
sub, err := client.Subscribe(context.Background(), "nftest", nc, "someSubscription", 3, 1)
324322
if err != nil {
325323
t.Fatal(err)
326324
}
@@ -349,8 +347,7 @@ func TestClientNotificationStorm(t *testing.T) {
349347
// Subscribe on the server. It will start sending many notifications
350348
// very quickly.
351349
nc := make(chan int)
352-
// todo
353-
sub, err := client.Subscribe(ctx, "nftest", "someSubscribe", "", "", nc, count, 0)
350+
sub, err := client.Subscribe(ctx, "nftest", nc, "someSubscription", count, 0)
354351
if err != nil {
355352
t.Fatal("can't subscribe:", err)
356353
}

gethrpc/subscription_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func TestServerUnsubscribe(t *testing.T) {
136136
p2.SetDeadline(time.Now().Add(10 * time.Second))
137137

138138
// Subscribe.
139-
p2.Write([]byte(`{"jsonrpc":"2.0","id":1,"method":"nftest2_someSubscription","params":[0,10]}`))
139+
p2.Write([]byte(`{"jsonrpc":"2.0","id":1,"method":"nftest2_subscribe","params":["someSubscription",0,10]}`))
140140

141141
// Handle received messages.
142142
resps := make(chan subConfirmation)
@@ -153,8 +153,7 @@ func TestServerUnsubscribe(t *testing.T) {
153153
}
154154

155155
// Unsubscribe and check that it is handled on the server side.
156-
157-
p2.Write([]byte(fmt.Sprintf("{\"jsonrpc\":\"2.0\",\"method\":\"nftest2_unsubscribe\",\"params\":[\"%v\"]}", sub.subid)))
156+
p2.Write([]byte(`{"jsonrpc":"2.0","method":"nftest2_unsubscribe","params":["` + sub.subid + `"]}`))
158157
for {
159158
select {
160159
case id := <-service.unsubscribed:

gethrpc/websocket_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestClientWebsocketPing(t *testing.T) {
130130
t.Fatalf("client dial error: %v", err)
131131
}
132132
resultChan := make(chan int)
133-
sub, err := client.Subscribe(ctx, "eth", "foo", "foo", "foo", resultChan)
133+
sub, err := client.EthSubscribe(ctx, resultChan, "foo")
134134
if err != nil {
135135
t.Fatalf("client subscribe error: %v", err)
136136
}

0 commit comments

Comments
 (0)