[#172] Use protobuf v2 API for go

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-10-19 21:51:59 +03:00 committed by Alex Vanin
parent b681b28e33
commit 8351c78f58
28 changed files with 95 additions and 93 deletions

View file

@ -47,7 +47,7 @@ protoc:
echo "⇒ Processing $$f "; \
protoc \
--proto_path=.:./vendor:./vendor/github.com/nspcc-dev/neofs-api:/usr/local/include \
--gofast_out=plugins=grpc,paths=source_relative:. $$f; \
--go_out=plugins=grpc,paths=source_relative:. $$f; \
done
rm -rf vendor

7
go.mod
View file

@ -3,8 +3,7 @@ module github.com/nspcc-dev/neofs-api-go
go 1.14
require (
github.com/gogo/protobuf v1.1.1
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.1
github.com/mr-tron/base58 v1.1.2
github.com/nspcc-dev/hrw v1.0.9
@ -12,10 +11,8 @@ require (
github.com/nspcc-dev/neofs-crypto v0.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.6.1
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
google.golang.org/grpc v1.29.1
google.golang.org/protobuf v1.23.0
)
// Used for debug reasons

12
go.sum
View file

@ -84,8 +84,8 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
@ -244,15 +244,11 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180318012157-96caea41033d/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
@ -265,8 +261,6 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=

View file

@ -8,6 +8,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/util/proto/test"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
type SomeEnum int32
@ -437,7 +438,7 @@ func testMarshal(t *testing.T, c stablePrimitives, tr test.Primitives, wrongFiel
wire, err = c.stableMarshal(nil, wrongField)
require.NoError(t, err)
wireGen, err := tr.Marshal()
wireGen, err := goproto.Marshal(&tr)
require.NoError(t, err)
if !wrongField {
@ -448,7 +449,7 @@ func testMarshal(t *testing.T, c stablePrimitives, tr test.Primitives, wrongFiel
}
result := new(test.Primitives)
err = result.Unmarshal(wire)
err = goproto.Unmarshal(wire, result)
require.NoError(t, err)
return result
@ -588,7 +589,7 @@ func testRepMarshal(t *testing.T, c stableRepPrimitives, tr test.RepPrimitives,
wire, err = c.stableMarshal(nil, wrongField)
require.NoError(t, err)
wireGen, err := tr.Marshal()
wireGen, err := goproto.Marshal(&tr)
require.NoError(t, err)
if !wrongField {
@ -599,7 +600,7 @@ func testRepMarshal(t *testing.T, c stableRepPrimitives, tr test.RepPrimitives,
}
result := new(test.RepPrimitives)
err = result.Unmarshal(wire)
err = goproto.Unmarshal(wire, result)
require.NoError(t, err)
return result

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -7,6 +7,7 @@ import (
grpc "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestDecimal_StableMarshal(t *testing.T) {
@ -17,7 +18,7 @@ func TestDecimal_StableMarshal(t *testing.T) {
wire, err := decimalFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
decimalTo := accounting.DecimalFromGRPCMessage(transport)
@ -33,7 +34,7 @@ func TestBalanceRequestBody_StableMarshal(t *testing.T) {
wire, err := requestBodyFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestBodyTo := accounting.BalanceRequestBodyFromGRPCMessage(transport)
@ -49,7 +50,7 @@ func TestBalanceResponseBody_StableMarshal(t *testing.T) {
wire, err := responseBodyFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseBodyTo := accounting.BalanceResponseBodyFromGRPCMessage(transport)

BIN
v2/acl/grpc/types.pb.go generated

Binary file not shown.

View file

@ -8,6 +8,7 @@ import (
grpc "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func generateTarget(u acl.Role, k int) *acl.Target {
@ -127,7 +128,7 @@ func TestHeaderFilter_StableMarshal(t *testing.T) {
wire, err := filterFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
filterTo := acl.HeaderFilterFromGRPCMessage(transport)
@ -149,7 +150,7 @@ func TestTargetInfo_StableMarshal(t *testing.T) {
wire, err := targetFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
targetTo := acl.TargetInfoFromGRPCMessage(transport)
@ -165,7 +166,7 @@ func TestRecord_StableMarshal(t *testing.T) {
wire, err := recordFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
recordTo := acl.RecordFromGRPCMessage(transport)
@ -195,7 +196,7 @@ func TestTable_StableMarshal(t *testing.T) {
wire, err := tableFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
tableTo := acl.TableFromGRPCMessage(transport)
@ -211,7 +212,7 @@ func TestTokenLifetime_StableMarshal(t *testing.T) {
wire, err := lifetimeFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
lifetimeTo := acl.TokenLifetimeFromGRPCMessage(transport)
@ -227,7 +228,7 @@ func TestBearerTokenBody_StableMarshal(t *testing.T) {
wire, err := bearerTokenBodyFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
bearerTokenBodyTo := acl.BearerTokenBodyFromGRPCMessage(transport)
@ -243,7 +244,7 @@ func TestBearerToken_StableMarshal(t *testing.T) {
wire, err := bearerTokenFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
bearerTokenTo := acl.BearerTokenFromGRPCMessage(transport)

Binary file not shown.

Binary file not shown.

View file

@ -9,6 +9,7 @@ import (
grpc "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestAttribute_StableMarshal(t *testing.T) {
@ -19,7 +20,7 @@ func TestAttribute_StableMarshal(t *testing.T) {
wire, err := attributeFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
attributeTo := container.AttributeFromGRPCMessage(transport)
@ -35,7 +36,7 @@ func TestContainer_StableMarshal(t *testing.T) {
wire, err := cnrFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
cnrTo := container.ContainerFromGRPCMessage(transport)
@ -51,7 +52,7 @@ func TestPutRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := container.PutRequestBodyFromGRPCMessage(transport)
@ -67,7 +68,7 @@ func TestPutResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := container.PutResponseBodyFromGRPCMessage(transport)
@ -83,7 +84,7 @@ func TestDeleteRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := container.DeleteRequestBodyFromGRPCMessage(transport)
@ -99,7 +100,7 @@ func TestDeleteResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := container.DeleteResponseBodyFromGRPCMessage(transport)
@ -115,7 +116,7 @@ func TestGetRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := container.GetRequestBodyFromGRPCMessage(transport)
@ -131,7 +132,7 @@ func TestGetResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := container.GetResponseBodyFromGRPCMessage(transport)
@ -147,7 +148,7 @@ func TestListRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := container.ListRequestBodyFromGRPCMessage(transport)
@ -163,7 +164,7 @@ func TestListResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := container.ListResponseBodyFromGRPCMessage(transport)
@ -179,7 +180,7 @@ func TestSetEACLRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := container.SetExtendedACLRequestBodyFromGRPCMessage(transport)
@ -195,7 +196,7 @@ func TestSetEACLResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := container.SetExtendedACLResponseBodyFromGRPCMessage(transport)
@ -211,7 +212,7 @@ func TestGetEACLRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := container.GetExtendedACLRequestBodyFromGRPCMessage(transport)
@ -227,7 +228,7 @@ func TestGetEACLResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := container.GetExtendedACLResponseBodyFromGRPCMessage(transport)

Binary file not shown.

Binary file not shown.

View file

@ -8,6 +8,7 @@ import (
grpc "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestAttribute_StableMarshal(t *testing.T) {
@ -18,7 +19,7 @@ func TestAttribute_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.AttributeFromGRPCMessage(transport)
@ -34,7 +35,7 @@ func TestNodeInfo_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.NodeInfoFromGRPCMessage(transport)
@ -50,7 +51,7 @@ func TestFilter_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.FilterFromGRPCMessage(transport)
@ -66,7 +67,7 @@ func TestSelector_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.SelectorFromGRPCMessage(transport)
@ -82,7 +83,7 @@ func TestReplica_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.ReplicaFromGRPCMessage(transport)
@ -98,7 +99,7 @@ func TestPlacementPolicy_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.PlacementPolicyFromGRPCMessage(transport)
@ -114,7 +115,7 @@ func TestLocalNodeInfoResponseBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := netmap.LocalNodeInfoResponseBodyFromGRPCMessage(transport)

Binary file not shown.

Binary file not shown.

View file

@ -3,6 +3,7 @@ package object
import (
"github.com/nspcc-dev/neofs-api-go/util/proto"
object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
goproto "google.golang.org/protobuf/proto"
)
const (
@ -492,7 +493,7 @@ func (o *Object) StableUnmarshal(data []byte) error {
}
objGRPC := new(object.Object)
if err := objGRPC.Unmarshal(data); err != nil {
if err := goproto.Unmarshal(data, objGRPC); err != nil {
return err
}

View file

@ -10,6 +10,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestShortHeader_StableMarshal(t *testing.T) {
@ -20,7 +21,7 @@ func TestShortHeader_StableMarshal(t *testing.T) {
wire, err := hdrFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
hdrTo := object.ShortHeaderFromGRPCMessage(transport)
@ -36,7 +37,7 @@ func TestAttribute_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.AttributeFromGRPCMessage(transport)
@ -55,7 +56,7 @@ func TestSplitHeader_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.SplitHeaderFromGRPCMessage(transport)
@ -77,7 +78,7 @@ func TestHeader_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.HeaderFromGRPCMessage(transport)
@ -93,7 +94,7 @@ func TestObject_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.ObjectFromGRPCMessage(transport)
@ -109,7 +110,7 @@ func TestGetRequestBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetRequestBodyFromGRPCMessage(transport)
@ -126,7 +127,7 @@ func TestGetResponseBody_StableMarshal(t *testing.T) {
wire, err := initFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetResponseBodyFromGRPCMessage(transport)
@ -137,7 +138,7 @@ func TestGetResponseBody_StableMarshal(t *testing.T) {
wire, err := chunkFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetResponseBodyFromGRPCMessage(transport)
@ -154,7 +155,7 @@ func TestPutRequestBody_StableMarshal(t *testing.T) {
wire, err := initFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.PutRequestBodyFromGRPCMessage(transport)
@ -165,7 +166,7 @@ func TestPutRequestBody_StableMarshal(t *testing.T) {
wire, err := chunkFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.PutRequestBodyFromGRPCMessage(transport)
@ -181,7 +182,7 @@ func TestPutRequestBody_StableSize(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.PutResponseBodyFromGRPCMessage(transport)
@ -197,7 +198,7 @@ func TestDeleteRequestBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.DeleteRequestBodyFromGRPCMessage(transport)
@ -213,7 +214,7 @@ func TestDeleteResponseBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.DeleteResponseBodyFromGRPCMessage(transport)
@ -229,7 +230,7 @@ func TestSplitHeaderFromGRPCMessage(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.HeadRequestBodyFromGRPCMessage(transport)
@ -246,7 +247,7 @@ func TestHeadResponseBody_StableMarshal(t *testing.T) {
wire, err := shortFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.HeadResponseBodyFromGRPCMessage(transport)
@ -257,7 +258,7 @@ func TestHeadResponseBody_StableMarshal(t *testing.T) {
wire, err := fullFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.HeadResponseBodyFromGRPCMessage(transport)
@ -273,7 +274,7 @@ func TestSearchRequestBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.SearchRequestBodyFromGRPCMessage(transport)
@ -289,7 +290,7 @@ func TestSearchResponseBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.SearchResponseBodyFromGRPCMessage(transport)
@ -305,7 +306,7 @@ func TestGetRangeRequestBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetRangeRequestBodyFromGRPCMessage(transport)
@ -321,7 +322,7 @@ func TestGetRangeResponseBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetRangeResponseBodyFromGRPCMessage(transport)
@ -337,7 +338,7 @@ func TestGetRangeHashRequestBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetRangeHashRequestBodyFromGRPCMessage(transport)
@ -353,7 +354,7 @@ func TestGetRangeHashResponseBody_StableMarshal(t *testing.T) {
wire, err := from.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
to := object.GetRangeHashResponseBodyFromGRPCMessage(transport)

BIN
v2/refs/grpc/types.pb.go generated

Binary file not shown.

View file

@ -3,6 +3,7 @@ package refs
import (
"github.com/nspcc-dev/neofs-api-go/util/proto"
refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
goproto "google.golang.org/protobuf/proto"
)
const (
@ -147,7 +148,7 @@ func (a *Address) StableUnmarshal(data []byte) error {
}
addrGRPC := new(refs.Address)
if err := addrGRPC.Unmarshal(data); err != nil {
if err := goproto.Unmarshal(data, addrGRPC); err != nil {
return err
}

View file

@ -6,6 +6,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
grpc "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestOwnerID_StableMarshal(t *testing.T) {
@ -18,7 +19,7 @@ func TestOwnerID_StableMarshal(t *testing.T) {
wire, err := ownerFrom.StableMarshal(nil)
require.NoError(t, err)
err = ownerTransport.Unmarshal(wire)
err = goproto.Unmarshal(wire, ownerTransport)
require.NoError(t, err)
ownerTo := refs.OwnerIDFromGRPCMessage(ownerTransport)
@ -36,7 +37,7 @@ func TestContainerID_StableMarshal(t *testing.T) {
wire, err := cnrFrom.StableMarshal(nil)
require.NoError(t, err)
err = cnrTransport.Unmarshal(wire)
err = goproto.Unmarshal(wire, cnrTransport)
require.NoError(t, err)
cnrTo := refs.ContainerIDFromGRPCMessage(cnrTransport)
@ -54,7 +55,7 @@ func TestObjectID_StableMarshal(t *testing.T) {
wire, err := objectIDFrom.StableMarshal(nil)
require.NoError(t, err)
err = objectIDTransport.Unmarshal(wire)
err = goproto.Unmarshal(wire, objectIDTransport)
require.NoError(t, err)
objectIDTo := refs.ObjectIDFromGRPCMessage(objectIDTransport)
@ -74,7 +75,7 @@ func TestAddress_StableMarshal(t *testing.T) {
wire, err := addressFrom.StableMarshal(nil)
require.NoError(t, err)
err = addressTransport.Unmarshal(wire)
err = goproto.Unmarshal(wire, addressTransport)
require.NoError(t, err)
addressTo := refs.AddressFromGRPCMessage(addressTransport)
@ -93,7 +94,7 @@ func TestChecksum_StableMarshal(t *testing.T) {
wire, err := checksumFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
checksumTo := refs.ChecksumFromGRPCMessage(transport)
@ -109,7 +110,7 @@ func TestSignature_StableMarshal(t *testing.T) {
wire, err := signatureFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
signatureTo := refs.SignatureFromGRPCMessage(transport)
@ -125,7 +126,7 @@ func TestVersion_StableMarshal(t *testing.T) {
wire, err := versionFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
versionTo := refs.VersionFromGRPCMessage(transport)

Binary file not shown.

Binary file not shown.

View file

@ -9,6 +9,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/session"
grpc "github.com/nspcc-dev/neofs-api-go/v2/session/grpc"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestCreateRequestBody_StableMarshal(t *testing.T) {
@ -19,7 +20,7 @@ func TestCreateRequestBody_StableMarshal(t *testing.T) {
wire, err := requestFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
requestTo := session.CreateRequestBodyFromGRPCMessage(transport)
@ -35,7 +36,7 @@ func TestCreateResponseBody_StableMarshal(t *testing.T) {
wire, err := responseFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
responseTo := session.CreateResponseBodyFromGRPCMessage(transport)
@ -51,7 +52,7 @@ func TestXHeader_StableMarshal(t *testing.T) {
wire, err := xheaderFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
xheaderTo := session.XHeaderFromGRPCMessage(transport)
@ -67,7 +68,7 @@ func TestTokenLifetime_StableMarshal(t *testing.T) {
wire, err := lifetimeFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
lifetimeTo := session.TokenLifetimeFromGRPCMessage(transport)
@ -83,7 +84,7 @@ func TestObjectSessionContext_StableMarshal(t *testing.T) {
wire, err := objectCtxFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
objectCtxTo := session.ObjectSessionContextFromGRPCMessage(transport)
@ -99,7 +100,7 @@ func TestSessionTokenBody_StableMarshal(t *testing.T) {
wire, err := sessionTokenBodyFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
sessionTokenBodyTo := session.SessionTokenBodyFromGRPCMessage(transport)
@ -115,7 +116,7 @@ func TestSessionToken_StableMarshal(t *testing.T) {
wire, err := sessionTokenFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
sessionTokenTo := session.SessionTokenFromGRPCMessage(transport)
@ -133,7 +134,7 @@ func TestRequestMetaHeader_StableMarshal(t *testing.T) {
wire, err := metaHeaderFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
metaHeaderTo := session.RequestMetaHeaderFromGRPCMessage(transport)
@ -151,7 +152,7 @@ func TestRequestVerificationHeader_StableMarshal(t *testing.T) {
wire, err := verifHeaderFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
verifHeaderTo := session.RequestVerificationHeaderFromGRPCMessage(transport)
@ -169,7 +170,7 @@ func TestResponseMetaHeader_StableMarshal(t *testing.T) {
wire, err := metaHeaderFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
metaHeaderTo := session.ResponseMetaHeaderFromGRPCMessage(transport)
@ -187,7 +188,7 @@ func TestResponseVerificationHeader_StableMarshal(t *testing.T) {
wire, err := verifHeaderFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
verifHeaderTo := session.ResponseVerificationHeaderFromGRPCMessage(transport)

Binary file not shown.

View file

@ -7,6 +7,7 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/storagegroup"
grpc "github.com/nspcc-dev/neofs-api-go/v2/storagegroup/grpc"
"github.com/stretchr/testify/require"
goproto "google.golang.org/protobuf/proto"
)
func TestStorageGroup_StableMarshal(t *testing.T) {
@ -28,7 +29,7 @@ func TestStorageGroup_StableMarshal(t *testing.T) {
wire, err := storageGroupFrom.StableMarshal(nil)
require.NoError(t, err)
err = transport.Unmarshal(wire)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
storageGroupTo := storagegroup.StorageGroupFromGRPCMessage(transport)