frostfs-sdk-go/netmap/netmap_test.go
Pavel Pogodaev 7ef502e2c0
Some checks failed
/ DCO (pull_request) Failing after 14s
/ Lint (pull_request) Failing after 1m23s
/ Tests (pull_request) Failing after 29s
[] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-07 17:20:25 +03:00

47 lines
963 B
Go

package netmap_test
import (
"testing"
v2netmap "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apiv2/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
netmaptest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap/test"
"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 := make([]v2netmap.NodeInfo, len(nodes))
for i := range nodes {
nodes[i].WriteToV2(&nodesV2[i])
}
var m v2netmap.NetMap
nm.WriteToV2(&m)
require.ElementsMatch(t, nodesV2, m.Nodes())
}
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 v2netmap.NetMap
nm.WriteToV2(&m)
require.EqualValues(t, e, m.Epoch())
}