forked from TrueCloudLab/frostfs-api-go
[#165] pkg/owner: Add ID constructor from wallet
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
cf70026c7e
commit
fa18f5ede7
2 changed files with 17 additions and 0 deletions
|
@ -43,3 +43,11 @@ func ScriptHashBE(id *ID) ([]byte, error) {
|
||||||
|
|
||||||
return addr.BytesBE(), nil
|
return addr.BytesBE(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewIDFromNeo3Wallet creates new owner identity from 25-byte neo wallet.
|
||||||
|
func NewIDFromNeo3Wallet(v *NEO3Wallet) *ID {
|
||||||
|
id := NewID()
|
||||||
|
id.SetNeo3Wallet(v)
|
||||||
|
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-crypto/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,3 +22,11 @@ func TestIDV2(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, wallet.Bytes(), idV2.GetValue())
|
require.Equal(t, wallet.Bytes(), idV2.GetValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue