[#166] v2/netmap: add v2 structures for netmap service
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
fa18f5ede7
commit
a29b615522
8 changed files with 555 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
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"
|
||||
)
|
||||
|
||||
|
@ -89,7 +90,7 @@ func TestReplica_StableMarshal(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_StableSize(t *testing.T) {
|
||||
func TestPlacementPolicy_StableMarshal(t *testing.T) {
|
||||
from := generatePolicy(3)
|
||||
transport := new(grpc.PlacementPolicy)
|
||||
|
||||
|
@ -105,6 +106,22 @@ func TestPlacementPolicy_StableSize(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestLocalNodeInfoResponseBody_StableMarshal(t *testing.T) {
|
||||
from := generateNodeInfoResponseBody()
|
||||
transport := new(grpc.LocalNodeInfoResponse_Body)
|
||||
|
||||
t.Run("non empty", func(t *testing.T) {
|
||||
wire, err := from.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = transport.Unmarshal(wire)
|
||||
require.NoError(t, err)
|
||||
|
||||
to := netmap.LocalNodeInfoResponseBodyFromGRPCMessage(transport)
|
||||
require.Equal(t, from, to)
|
||||
})
|
||||
}
|
||||
|
||||
func generateAttribute(k, v string) *netmap.Attribute {
|
||||
attr := new(netmap.Attribute)
|
||||
attr.SetKey(k)
|
||||
|
@ -189,3 +206,21 @@ func generatePolicy(n int) *netmap.PlacementPolicy {
|
|||
|
||||
return p
|
||||
}
|
||||
|
||||
func generateNodeInfoResponseBody() *netmap.LocalNodeInfoResponseBody {
|
||||
ni := generateNodeInfo("key", "/multi/addr", 2)
|
||||
|
||||
r := new(netmap.LocalNodeInfoResponseBody)
|
||||
r.SetVersion(generateVersion(2, 1))
|
||||
r.SetNodeInfo(ni)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func generateVersion(maj, min uint32) *refs.Version {
|
||||
version := new(refs.Version)
|
||||
version.SetMajor(maj)
|
||||
version.SetMinor(min)
|
||||
|
||||
return version
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue