diff options
Diffstat (limited to 'rpc/server_test.go')
-rw-r--r-- | rpc/server_test.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/rpc/server_test.go b/rpc/server_test.go index de47e1afd..e6840bde4 100644 --- a/rpc/server_test.go +++ b/rpc/server_test.go @@ -21,6 +21,7 @@ import ( "net" "reflect" "testing" + "time" "golang.org/x/net/context" ) @@ -48,6 +49,13 @@ func (s *Service) EchoWithCtx(ctx context.Context, str string, i int, args *Args return Result{str, i, args} } +func (s *Service) Sleep(ctx context.Context, duration time.Duration) { + select { + case <-time.After(duration): + case <-ctx.Done(): + } +} + func (s *Service) Rets() (string, error) { return "", nil } @@ -85,8 +93,8 @@ func TestServerRegisterName(t *testing.T) { t.Fatalf("Expected service calc to be registered") } - if len(svc.callbacks) != 4 { - t.Errorf("Expected 4 callbacks for service 'calc', got %d", len(svc.callbacks)) + if len(svc.callbacks) != 5 { + t.Errorf("Expected 5 callbacks for service 'calc', got %d", len(svc.callbacks)) } if len(svc.subscriptions) != 1 { @@ -126,7 +134,7 @@ func testServerMethodExecution(t *testing.T, method string) { t.Fatal(err) } - response := JSONSuccessResponse{Result: &Result{}} + response := jsonSuccessResponse{Result: &Result{}} if err := in.Decode(&response); err != nil { t.Fatal(err) } |