2020-08-31 07:46:10 +00:00
|
|
|
package owner
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"testing"
|
|
|
|
|
2020-10-06 06:56:28 +00:00
|
|
|
"github.com/nspcc-dev/neofs-crypto/test"
|
2020-08-31 07:46:10 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIDV2(t *testing.T) {
|
2020-09-10 09:57:29 +00:00
|
|
|
id := NewID()
|
2020-08-31 07:46:10 +00:00
|
|
|
|
2020-08-31 08:15:46 +00:00
|
|
|
wallet := new(NEO3Wallet)
|
2020-08-31 07:46:10 +00:00
|
|
|
|
|
|
|
_, err := rand.Read(wallet.Bytes())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
id.SetNeo3Wallet(wallet)
|
|
|
|
|
|
|
|
idV2 := id.ToV2()
|
|
|
|
|
2020-09-10 09:57:29 +00:00
|
|
|
require.Equal(t, wallet.Bytes(), idV2.GetValue())
|
2020-08-31 07:46:10 +00:00
|
|
|
}
|
2020-10-06 06:56:28 +00:00
|
|
|
|
|
|
|
func TestNewIDFromNeo3Wallet(t *testing.T) {
|
|
|
|
wallet, err := NEO3WalletFromPublicKey(&test.DecodeKey(1).PublicKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
id := NewIDFromNeo3Wallet(wallet)
|
|
|
|
require.Equal(t, id.ToV2().GetValue(), wallet.Bytes())
|
|
|
|
}
|