forked from TrueCloudLab/frostfs-api-go
1958ff8c37
With neo-go v0.90.0 there are new event subscription component and new verification script routines based on NEO3. These features allow to avoid using low-level neo-vm code in NeoFS and corresponding projects. This commit removes unused function: - FetchPublicKeys (used in neofs indexer), - VerificationScript (used in KeysToAddress), - Address (used in KeysToAddress), - ReversedScriptHashToAddress (used in neofs indexer), - IsAddress (used in neofs indexer), - ReverseBytes (used in neofs indexer), - DecodeScriptHash (used in neofs indexer). KeysToAddress changed into KeyToAddress because NeoFS won't work with multisignature owners for now and it is not supported in neo-go library.
41 lines
732 B
Go
41 lines
732 B
Go
package chain
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
type addressTestCase struct {
|
|
name string
|
|
publicKey string
|
|
wallet string
|
|
}
|
|
|
|
func TestKeyToAddress(t *testing.T) {
|
|
tests := []addressTestCase{
|
|
{
|
|
"nil key",
|
|
"",
|
|
"",
|
|
},
|
|
{
|
|
"correct key",
|
|
"031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a",
|
|
"NgzuJWWGVEwFGsRrgzj8knswEYRJrTe7sm",
|
|
},
|
|
}
|
|
|
|
for i := range tests {
|
|
t.Run(tests[i].name, func(t *testing.T) {
|
|
data, err := hex.DecodeString(tests[i].publicKey)
|
|
require.NoError(t, err)
|
|
|
|
key := crypto.UnmarshalPublicKey(data)
|
|
|
|
require.Equal(t, tests[i].wallet, KeyToAddress(key))
|
|
})
|
|
}
|
|
}
|