neoneo-go/pkg/core/native/noderoles/role_test.go
Anna Shaleva 61a74ab331 native: introduce Stringer for noderoles types
And rename roles.go to role.go to match the role_string.go and the
existing naming pattern for enums.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-19 11:33:04 +03:00

27 lines
531 B
Go

package noderoles
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFromString(t *testing.T) {
valid := map[string]Role{
"StateValidator": StateValidator,
"Oracle": Oracle,
"NeoFSAlphabet": NeoFSAlphabet,
"P2PNotary": P2PNotary,
}
for s, expected := range valid {
actual, ok := FromString(s)
require.True(t, ok)
require.Equal(t, expected, actual)
}
invalid := []string{"last", "InvalidRole"}
for _, s := range invalid {
_, ok := FromString(s)
require.False(t, ok)
}
}