smartcontract: fix underlying PublicKey parameter value

Value of PublicKey parameter always stores public key bytes, not the
deserialized representation. All other code (CLI parameters parsing with
its NewParameterFromString, Parameter unmarshaller, etc.) is based on
the idea that value of PublicKey is []byte.
This commit is contained in:
Anna Shaleva 2022-10-11 13:34:14 +03:00
parent 478b4b0c1c
commit 641abd4d1c
2 changed files with 1 additions and 3 deletions

View file

@ -387,8 +387,6 @@ func NewParametersFromValues(values ...interface{}) ([]Parameter, error) {
func ExpandParameterToEmitable(param Parameter) (interface{}, error) { func ExpandParameterToEmitable(param Parameter) (interface{}, error) {
var err error var err error
switch t := param.Type; t { switch t := param.Type; t {
case PublicKeyType:
return param.Value.(*keys.PublicKey).Bytes(), nil
case ArrayType: case ArrayType:
arr := param.Value.([]Parameter) arr := param.Value.([]Parameter)
res := make([]interface{}, len(arr)) res := make([]interface{}, len(arr))

View file

@ -477,7 +477,7 @@ func TestExpandParameterToEmitable(t *testing.T) {
Expected: util.Uint256{1, 2, 3}, Expected: util.Uint256{1, 2, 3},
}, },
{ {
In: Parameter{Type: PublicKeyType, Value: pk.PublicKey()}, In: Parameter{Type: PublicKeyType, Value: pk.PublicKey().Bytes()},
Expected: pk.PublicKey().Bytes(), Expected: pk.PublicKey().Bytes(),
}, },
{ {