frostfs-node/pkg/morph/event/rolemanagement/designate_test.go
Evgenii Stratonikov 07465849a4 [] go.mod: Update neo-go to v0.99.1
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
2022-07-28 20:11:45 +03:00

36 lines
1.1 KiB
Go

package rolemanagement
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/stretchr/testify/require"
)
func TestParseRoleUpdate(t *testing.T) {
t.Run("wrong number of arguments", func(t *testing.T) {
_, err := ParseDesignate(createNotifyEventFromItems([]stackitem.Item{}))
require.Error(t, err)
})
t.Run("invalid item type", func(t *testing.T) {
args := []stackitem.Item{stackitem.NewMap(), stackitem.Make(123)}
_, err := ParseDesignate(createNotifyEventFromItems(args))
require.Error(t, err)
})
t.Run("good", func(t *testing.T) {
args := []stackitem.Item{stackitem.Make(int(noderoles.NeoFSAlphabet)), stackitem.Make(123)}
e, err := ParseDesignate(createNotifyEventFromItems(args))
require.NoError(t, err)
require.Equal(t, noderoles.NeoFSAlphabet, e.(Designate).Role)
})
}
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
return &state.ContainedNotificationEvent{
NotificationEvent: state.NotificationEvent{
Item: stackitem.NewArray(items),
},
}
}