fix a malformed error status

This commit is contained in:
iamqizhao 2015-03-23 11:47:27 -07:00
parent c71f1d16c1
commit 9c6754e004
2 changed files with 12 additions and 1 deletions

View File

@ -147,7 +147,7 @@ func Invoke(ctx context.Context, method string, args, reply proto.Message, cc *C
// This was a retry; return the error from the last attempt.
return toRPCErr(lastErr)
}
return Errorf(codes.Internal, "%v", err)
return toRPCErr(err)
}
stream, err = sendRPC(ctx, callHdr, t, args, topts)
if err != nil {

View File

@ -301,6 +301,17 @@ func setUp(useTLS bool, maxStream uint32) (s *grpc.Server, tc testpb.TestService
return
}
func TestTimeoutOnDeadServer(t *testing.T) {
s, tc := setUp(false, math.MaxUint32)
s.Stop()
// Set a minimal deadline to make sure the context times out in the 1st
// invoke of ClientConn.wait.
ctx, _ := context.WithTimeout(context.Background(), time.Nanosecond)
if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); grpc.Code(err) != codes.DeadlineExceeded {
t.Fatalf("TestService/EmptyCall(%v, _) = _, error %v, want _, error code: %d", ctx, err, codes.DeadlineExceeded)
}
}
func TestEmptyUnary(t *testing.T) {
s, tc := setUp(true, math.MaxUint32)
defer s.Stop()