diff --git a/accounting/grpc/service_frostfs.pb.go b/accounting/grpc/service_frostfs.pb.go index e44d7d4..b70fd27 100644 Binary files a/accounting/grpc/service_frostfs.pb.go and b/accounting/grpc/service_frostfs.pb.go differ diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index e542a19..931f3b3 100644 Binary files a/acl/grpc/types_frostfs.pb.go and b/acl/grpc/types_frostfs.pb.go differ diff --git a/apemanager/grpc/service_frostfs.pb.go b/apemanager/grpc/service_frostfs.pb.go index 380ba30..c1d28ed 100644 Binary files a/apemanager/grpc/service_frostfs.pb.go and b/apemanager/grpc/service_frostfs.pb.go differ diff --git a/container/grpc/service_frostfs.pb.go b/container/grpc/service_frostfs.pb.go index 7590435..514f03b 100644 Binary files a/container/grpc/service_frostfs.pb.go and b/container/grpc/service_frostfs.pb.go differ diff --git a/container/grpc/types_frostfs.pb.go b/container/grpc/types_frostfs.pb.go index 3e0d882..dcb9cf4 100644 Binary files a/container/grpc/types_frostfs.pb.go and b/container/grpc/types_frostfs.pb.go differ diff --git a/lock/grpc/types_frostfs.pb.go b/lock/grpc/types_frostfs.pb.go index 3012111..52a1a2d 100644 Binary files a/lock/grpc/types_frostfs.pb.go and b/lock/grpc/types_frostfs.pb.go differ diff --git a/netmap/grpc/service_frostfs.pb.go b/netmap/grpc/service_frostfs.pb.go index 1ce80ff..3d62855 100644 Binary files a/netmap/grpc/service_frostfs.pb.go and b/netmap/grpc/service_frostfs.pb.go differ diff --git a/netmap/grpc/types_frostfs.pb.go b/netmap/grpc/types_frostfs.pb.go index 3bab079..6ecf0fa 100644 Binary files a/netmap/grpc/types_frostfs.pb.go and b/netmap/grpc/types_frostfs.pb.go differ diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index ce8336a..0bd0111 100644 Binary files a/object/grpc/service_frostfs.pb.go and b/object/grpc/service_frostfs.pb.go differ diff --git a/object/grpc/types_frostfs.pb.go b/object/grpc/types_frostfs.pb.go index 492ee48..04a3e29 100644 Binary files a/object/grpc/types_frostfs.pb.go and b/object/grpc/types_frostfs.pb.go differ diff --git a/refs/grpc/types_frostfs.pb.go b/refs/grpc/types_frostfs.pb.go index 881a06f..35febe9 100644 Binary files a/refs/grpc/types_frostfs.pb.go and b/refs/grpc/types_frostfs.pb.go differ diff --git a/rpc/message/test/message.go b/rpc/message/test/message.go index 435f20a..0849b20 100644 --- a/rpc/message/test/message.go +++ b/rpc/message/test/message.go @@ -7,6 +7,7 @@ import ( "testing" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" + "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto/encoding" "github.com/stretchr/testify/require" ) @@ -68,6 +69,63 @@ func TestRPCMessage(t *testing.T, msgGens ...func(empty bool) message.Message) { require.Equal(t, bm, bm2) }) } + t.Run("compatibility", func(t *testing.T) { + testCompatibility(t, msgGen) + }) }) } } + +func testCompatibility(t *testing.T, msgGen func(empty bool) message.Message) { + compareBinary := func(t *testing.T, msg message.Message) { + am, ok := msg.(binaryMessage) + if !ok { + t.Skip() + } + + a := am.StableMarshal(nil) + b := msg.ToGRPCMessage().(encoding.ProtoMarshaler).MarshalProtobuf(nil) + if len(a) == 0 { + require.Empty(t, b) + } else { + require.Equal(t, a, b) + } + } + compareJSON := func(t *testing.T, msg message.Message) { + am, ok := msg.(jsonMessage) + if !ok { + t.Skip() + } + + a, err := am.MarshalJSON() + require.NoError(t, err) + + b, err := json.Marshal(msg.ToGRPCMessage()) + require.NoError(t, err) + + require.JSONEq(t, string(a), string(b)) + if len(a) == 0 { + require.Empty(t, b) + } else { + require.Equal(t, a, b) + } + } + t.Run("empty", func(t *testing.T) { + msg := msgGen(true) + t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) { + compareBinary(t, msg) + }) + t.Run(fmt.Sprintf("JSON_%T", msg), func(t *testing.T) { + compareJSON(t, msg) + }) + }) + t.Run("not empty", func(t *testing.T) { + msg := msgGen(false) + t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) { + compareBinary(t, msg) + }) + t.Run(fmt.Sprintf("JSON_%T", msg), func(t *testing.T) { + compareJSON(t, msg) + }) + }) +} diff --git a/session/grpc/service_frostfs.pb.go b/session/grpc/service_frostfs.pb.go index cfec4d6..aa42ee8 100644 Binary files a/session/grpc/service_frostfs.pb.go and b/session/grpc/service_frostfs.pb.go differ diff --git a/session/grpc/types_frostfs.pb.go b/session/grpc/types_frostfs.pb.go index af95210..4f8bf81 100644 Binary files a/session/grpc/types_frostfs.pb.go and b/session/grpc/types_frostfs.pb.go differ diff --git a/status/grpc/types_frostfs.pb.go b/status/grpc/types_frostfs.pb.go index a12ab55..5012491 100644 Binary files a/status/grpc/types_frostfs.pb.go and b/status/grpc/types_frostfs.pb.go differ diff --git a/tombstone/grpc/types_frostfs.pb.go b/tombstone/grpc/types_frostfs.pb.go index b0924c0..8c2e83c 100644 Binary files a/tombstone/grpc/types_frostfs.pb.go and b/tombstone/grpc/types_frostfs.pb.go differ diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index b1d2cf2..a39bba7 100644 Binary files a/util/proto/test/custom/test_frostfs.pb.go and b/util/proto/test/custom/test_frostfs.pb.go differ diff --git a/util/protogen/internalgengo/proto.go b/util/protogen/internalgengo/proto.go index 8e5e967..8894cde 100644 --- a/util/protogen/internalgengo/proto.go +++ b/util/protogen/internalgengo/proto.go @@ -174,7 +174,7 @@ func emitMarshalRaw(g *protogen.GeneratedFile, f *protogen.Field, name string) { name += "[i]" } - g.P("if ", notNil(name), " && ", name, ".StableSize() != 0 {") + g.P("if ", notNil(name), " {") g.P(name, ".EmitProtobuf(mm.AppendMessage(", f.Desc.Number(), "))") g.P("}") return