package morph import ( "encoding/hex" "testing" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/spf13/viper" "github.com/stretchr/testify/require" ) func TestFrostfsIDConfig(t *testing.T) { pks := make([]*keys.PrivateKey, 4) for i := range pks { pk, err := keys.NewPrivateKey() require.NoError(t, err) pks[i] = pk } v := viper.New() v.Set("frostfsid.authorized_keys", []string{ pks[0].GetScriptHash().StringLE(), address.Uint160ToString(pks[1].GetScriptHash()), hex.EncodeToString(pks[2].PublicKey().UncompressedBytes()), hex.EncodeToString(pks[3].PublicKey().Bytes()), }) actual, err := getFrostfsIDAuthorizedKeys(v) require.NoError(t, err) require.Equal(t, len(pks), len(actual)) for i := range pks { require.Equal(t, smartcontract.Hash160Type, actual[i].Type) require.Equal(t, pks[i].GetScriptHash(), actual[i].Value) } t.Run("bad key", func(t *testing.T) { v := viper.New() v.Set("frostfsid.authorized_keys", []string{"abc"}) _, err := getFrostfsIDAuthorizedKeys(v) require.Error(t, err) }) }