[#562] pkg/morph: remove neofs-crypto uses

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-05-31 11:55:40 +03:00 committed by Alex Vanin
parent fcdef227e4
commit 5cab0026c3
6 changed files with 30 additions and 52 deletions

View file

@ -1,22 +1,22 @@
package netmap
import (
"crypto/elliptic"
"math/big"
"testing"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
crypto "github.com/nspcc-dev/neofs-crypto"
"github.com/nspcc-dev/neofs-crypto/test"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/stretchr/testify/require"
)
func TestParseUpdatePeer(t *testing.T) {
priv, err := keys.NewPrivateKey()
require.NoError(t, err)
var (
publicKey = &test.DecodeKey(-1).PublicKey
publicKey = priv.PublicKey()
state = netmap.NodeStateOffline
)
@ -39,7 +39,7 @@ func TestParseUpdatePeer(t *testing.T) {
t.Run("wrong second parameter type", func(t *testing.T) {
_, err := ParseUpdatePeer([]stackitem.Item{
stackitem.NewByteArray(crypto.MarshalPublicKey(publicKey)),
stackitem.NewByteArray(publicKey.Bytes()),
stackitem.NewMap(),
})
@ -49,15 +49,12 @@ func TestParseUpdatePeer(t *testing.T) {
t.Run("correct behavior", func(t *testing.T) {
ev, err := ParseUpdatePeer([]stackitem.Item{
stackitem.NewBigInteger(new(big.Int).SetInt64(int64(state.ToV2()))),
stackitem.NewByteArray(crypto.MarshalPublicKey(publicKey)),
stackitem.NewByteArray(publicKey.Bytes()),
})
require.NoError(t, err)
expectedKey, err := keys.NewPublicKeyFromBytes(crypto.MarshalPublicKey(publicKey), elliptic.P256())
require.NoError(t, err)
require.Equal(t, UpdatePeer{
publicKey: expectedKey,
publicKey: publicKey,
status: state,
}, ev)
})