2022-04-11 06:30:22 +00:00
|
|
|
package user_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/elliptic"
|
|
|
|
"encoding/hex"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/user"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIDFromKey(t *testing.T) {
|
|
|
|
// examples are taken from https://docs.neo.org/docs/en-us/basic/concept/wallets.html
|
|
|
|
rawPub, _ := hex.DecodeString("03cdb067d930fd5adaa6c68545016044aaddec64ba39e548250eaea551172e535c")
|
|
|
|
x, y := elliptic.UnmarshalCompressed(elliptic.P256(), rawPub)
|
|
|
|
require.True(t, x != nil && y != nil)
|
|
|
|
|
|
|
|
var id user.ID
|
|
|
|
|
2023-04-25 09:11:42 +00:00
|
|
|
require.NoError(t, user.IDFromKey(&id, rawPub))
|
2022-04-11 06:30:22 +00:00
|
|
|
|
|
|
|
require.Equal(t, "NNLi44dJNXtDNSBkofB48aTVYtb1zZrNEs", id.EncodeToString())
|
|
|
|
}
|