MCPcopy Create free account
hub / github.com/CPChain/chain / TestClientSubscribeInvalidArg

Function TestClientSubscribeInvalidArg

api/rpc/client_test.go:193–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func TestClientSubscribeInvalidArg(t *testing.T) {
194 server := newTestServer("service", new(Service))
195 defer server.Stop()
196 client := DialInProc(server)
197 defer client.Close()
198
199 check := func(shouldPanic bool, arg interface{}) {
200 defer func() {
201 err := recover()
202 if shouldPanic && err == nil {
203 t.Errorf("EthSubscribe should've panicked for %#v", arg)
204 }
205 if !shouldPanic && err != nil {
206 t.Errorf("EthSubscribe shouldn't have panicked for %#v", arg)
207 buf := make([]byte, 1024*1024)
208 buf = buf[:runtime.Stack(buf, false)]
209 t.Error(err)
210 t.Error(string(buf))
211 }
212 }()
213 client.EthSubscribe(context.Background(), arg, "foo_bar")
214 }
215 check(true, nil)
216 check(true, 1)
217 check(true, (chan int)(nil))
218 check(true, make(<-chan int))
219 check(false, make(chan int))
220 check(false, make(chan<- int))
221}
222
223func TestClientSubscribe(t *testing.T) {
224 server := newTestServer("eth", new(NotificationTestService))

Callers

nothing calls this directly

Calls 6

newTestServerFunction · 0.85
DialInProcFunction · 0.85
EthSubscribeMethod · 0.80
StopMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected