mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
28 lines
531 B
Go
28 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)
|
||
|
}
|
||
|
}
|