MCPcopy
hub / github.com/grpc/grpc-go / TestGzipBadChecksum

Method TestGzipBadChecksum

test/compressor_test.go:671–694  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

669}
670
671func (s) TestGzipBadChecksum(t *testing.T) {
672 ss := &stubserver.StubServer{
673 UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
674 return &testpb.SimpleResponse{}, nil
675 },
676 }
677 if err := ss.Start(nil, grpc.WithCompressor(badGzipCompressor{})); err != nil {
678 t.Fatalf("Error starting endpoint server: %v", err)
679 }
680 defer ss.Stop()
681
682 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
683 defer cancel()
684
685 p, err := newPayload(testpb.PayloadType_COMPRESSABLE, int32(1024))
686 if err != nil {
687 t.Fatalf("Unexpected error from newPayload: %v", err)
688 }
689 if _, err := ss.Client.UnaryCall(ctx, &testpb.SimpleRequest{Payload: p}); err == nil ||
690 status.Code(err) != codes.Internal ||
691 !strings.Contains(status.Convert(err).Message(), gzip.ErrChecksum.Error()) {
692 t.Errorf("ss.Client.UnaryCall(_) = _, %v\n\twant: _, status(codes.Internal, contains %q)", err, gzip.ErrChecksum)
693 }
694}

Callers

nothing calls this directly

Calls 11

StartMethod · 0.95
StopMethod · 0.95
WithCompressorFunction · 0.92
CodeFunction · 0.92
ConvertFunction · 0.92
newPayloadFunction · 0.85
MessageMethod · 0.80
FatalfMethod · 0.65
UnaryCallMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected