49 lines
1 KiB
Go
49 lines
1 KiB
Go
package netmap_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
netmapgrpc "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap/grpc"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
|
netmaptest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap/test"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/util/slices"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNetMapNodes(t *testing.T) {
|
|
var nm netmap.NetMap
|
|
|
|
require.Empty(t, nm.Nodes())
|
|
|
|
nodes := []netmap.NodeInfo{netmaptest.NodeInfo(), netmaptest.NodeInfo()}
|
|
|
|
nm.SetNodes(nodes)
|
|
require.ElementsMatch(t, nodes, nm.Nodes())
|
|
|
|
nodesV2 := slices.MakePreallocPointerSlice[netmapgrpc.NodeInfo](len(nodes))
|
|
|
|
for i := range nodes {
|
|
nodes[i].WriteToV2(nodesV2[i])
|
|
}
|
|
|
|
var m netmapgrpc.Netmap
|
|
nm.WriteToV2(&m)
|
|
|
|
require.ElementsMatch(t, nodesV2, m.GetNodes())
|
|
}
|
|
|
|
func TestNetMap_SetEpoch(t *testing.T) {
|
|
var nm netmap.NetMap
|
|
|
|
require.Zero(t, nm.Epoch())
|
|
|
|
const e = 158
|
|
|
|
nm.SetEpoch(e)
|
|
require.EqualValues(t, e, nm.Epoch())
|
|
|
|
var m netmapgrpc.Netmap
|
|
nm.WriteToV2(&m)
|
|
|
|
require.EqualValues(t, e, m.GetEpoch())
|
|
}
|