forked from andeya/erpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
erpc_test.go
45 lines (38 loc) · 901 Bytes
/
erpc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package erpc_test
import (
"testing"
"time"
"github.com/henrylee2cn/erpc/v6"
)
func panic_call(erpc.CallCtx, *interface{}) (interface{}, *erpc.Status) {
panic("panic_call")
}
func panic_push(erpc.PushCtx, *interface{}) *erpc.Status {
panic("panic_push")
}
func TestPanic(t *testing.T) {
srv := erpc.NewPeer(erpc.PeerConfig{
CountTime: true,
ListenPort: 9090,
})
srv.RouteCallFunc(panic_call)
srv.RoutePushFunc(panic_push)
go srv.ListenAndServe()
time.Sleep(2 * time.Second)
cli := erpc.NewPeer(erpc.PeerConfig{})
defer cli.Close()
sess, stat := cli.Dial(":9090")
if !stat.OK() {
t.Fatal(stat)
}
stat = sess.Call("/panic/call", nil, nil).Status()
if stat.OK() {
t.Fatalf("/panic/call: expect error!")
}
t.Logf("/panic/call error: %v", stat)
stat = sess.Push("/panic/push", nil)
if !stat.OK() {
t.Fatalf("/panic/push: expect ok!")
}
t.Logf("/panic/push: ok")
}