2021-11-23 18:20:12 +00:00
|
|
|
package subnet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-11-26 11:03:27 +00:00
|
|
|
. "github.com/nspcc-dev/neofs-sdk-go/subnet"
|
2021-11-23 18:20:12 +00:00
|
|
|
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
2022-06-15 07:12:35 +00:00
|
|
|
subnetidtest "github.com/nspcc-dev/neofs-sdk-go/subnet/id/test"
|
|
|
|
subnettest "github.com/nspcc-dev/neofs-sdk-go/subnet/test"
|
2022-04-11 06:30:22 +00:00
|
|
|
usertest "github.com/nspcc-dev/neofs-sdk-go/user/test"
|
2021-11-23 18:20:12 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestInfoZero(t *testing.T) {
|
2021-11-26 11:03:27 +00:00
|
|
|
var info Info
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Zero(t, info.ID())
|
|
|
|
require.True(t, subnetid.IsZero(info.ID()))
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestInfo_SetID(t *testing.T) {
|
2022-06-15 07:12:35 +00:00
|
|
|
id := subnetidtest.ID()
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
var info Info
|
2021-11-26 11:03:27 +00:00
|
|
|
info.SetID(id)
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Equal(t, id, info.ID())
|
|
|
|
require.True(t, AssertReference(info, id))
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestInfo_SetOwner(t *testing.T) {
|
2023-04-25 09:11:42 +00:00
|
|
|
id := *usertest.ID(t)
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
var info Info
|
2021-11-26 11:03:27 +00:00
|
|
|
info.SetOwner(id)
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Equal(t, id, info.Owner())
|
|
|
|
require.True(t, AssertOwnership(info, id))
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
func TestInfo_Marshal(t *testing.T) {
|
2023-04-25 09:11:42 +00:00
|
|
|
info := subnettest.Info(t)
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
var info2 Info
|
|
|
|
require.NoError(t, info2.Unmarshal(info.Marshal()))
|
2021-11-23 18:20:12 +00:00
|
|
|
|
2022-06-15 07:12:35 +00:00
|
|
|
require.Equal(t, info, info2)
|
2021-11-23 18:20:12 +00:00
|
|
|
}
|