mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
61a74ab331
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>
27 lines
531 B
Go
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)
|
|
}
|
|
}
|