stackitem: change ByteArray type to ByteString
Adjust only string representation. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
87119da2f7
commit
b53f0257f5
9 changed files with 36 additions and 36 deletions
|
@ -293,21 +293,21 @@ Example:
|
|||
"value" : [
|
||||
{
|
||||
"value" : "636f6e74726163742063616c6c",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : "7472616e73666572",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : [
|
||||
{
|
||||
"value" : "769162241eedf97c2481652adf1ba0f5bf57431b",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : "316e851039019d39dfc2c37d6c3fee19fd580987",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : "1000",
|
||||
|
@ -351,20 +351,20 @@ Example:
|
|||
"value" : [
|
||||
{
|
||||
"value" : "636f6e74726163742063616c6c",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"type" : "ByteArray",
|
||||
"type" : "ByteString",
|
||||
"value" : "7472616e73666572"
|
||||
},
|
||||
{
|
||||
"value" : [
|
||||
{
|
||||
"value" : "769162241eedf97c2481652adf1ba0f5bf57431b",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"type" : "ByteArray",
|
||||
"type" : "ByteString",
|
||||
"value" : "316e851039019d39dfc2c37d6c3fee19fd580987"
|
||||
},
|
||||
{
|
||||
|
@ -384,15 +384,15 @@ Example:
|
|||
"value" : [
|
||||
{
|
||||
"value" : "7472616e73666572",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : "769162241eedf97c2481652adf1ba0f5bf57431b",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : "316e851039019d39dfc2c37d6c3fee19fd580987",
|
||||
"type" : "ByteArray"
|
||||
"type" : "ByteString"
|
||||
},
|
||||
{
|
||||
"value" : "1000",
|
||||
|
|
|
@ -206,7 +206,7 @@ func (c *codegen) scTypeFromExpr(typ ast.Expr) string {
|
|||
return "Struct"
|
||||
case *types.Slice:
|
||||
if isByte(t.Elem()) {
|
||||
return "ByteArray"
|
||||
return "ByteString"
|
||||
}
|
||||
return "Array"
|
||||
default:
|
||||
|
|
|
@ -63,7 +63,7 @@ func unexportedMethod() int { return 1 }
|
|||
returnTypes := map[string]string{
|
||||
"MethodInt": "Integer",
|
||||
"MethodConcat": "String",
|
||||
"MethodString": "String", "MethodByteArray": "ByteArray",
|
||||
"MethodString": "String", "MethodByteArray": "ByteString",
|
||||
"MethodArray": "Array", "MethodStruct": "Struct",
|
||||
"Main": "Boolean",
|
||||
"unexportedMethod": "Integer",
|
||||
|
@ -272,7 +272,7 @@ func TestDebugInfo_MarshalJSON(t *testing.T) {
|
|||
{"param1", "Integer"},
|
||||
{"ok", "Boolean"},
|
||||
},
|
||||
ReturnType: "ByteArray",
|
||||
ReturnType: "ByteString",
|
||||
Variables: []string{},
|
||||
SeqPoints: []DebugSeqPoint{
|
||||
{
|
||||
|
|
|
@ -638,7 +638,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
Account: util.Uint160{1, 2, 3},
|
||||
}})
|
||||
},
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"1426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf","state":"HALT","gasconsumed":"31100000","stack":[{"type":"ByteArray","value":"JivsCEQy"}],"tx":"d101361426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf000000000000000000000000"}}`,
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"1426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf","state":"HALT","gasconsumed":"31100000","stack":[{"type":"ByteString","value":"JivsCEQy"}],"tx":"d101361426ae7c6c9861ec418468c1f0fdc4a7f2963eb89151c10962616c616e63654f6667be39e7b562f60cbfe2aebca375a2e5ee28737caf000000000000000000000000"}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
bytes, err := hex.DecodeString("262bec084432")
|
||||
if err != nil {
|
||||
|
@ -670,7 +670,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
Account: util.Uint160{1, 2, 3},
|
||||
}})
|
||||
},
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"00046e616d656724058e5e1b6008847cd662728549088a9ee82191","state":"HALT","gasconsumed":"16100000","stack":[{"type":"ByteArray","value":"TkVQNSBHQVM="}],"tx":"d1011b00046e616d656724058e5e1b6008847cd662728549088a9ee82191000000000000000000000000"}}`,
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"script":"00046e616d656724058e5e1b6008847cd662728549088a9ee82191","state":"HALT","gasconsumed":"16100000","stack":[{"type":"ByteString","value":"TkVQNSBHQVM="}],"tx":"d1011b00046e616d656724058e5e1b6008847cd662728549088a9ee82191000000000000000000000000"}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
bytes, err := hex.DecodeString("4e45503520474153")
|
||||
if err != nil {
|
||||
|
|
|
@ -116,9 +116,9 @@ func TestWSClientEvents(t *testing.T) {
|
|||
var ok bool
|
||||
// Events from RPC server test chain.
|
||||
var events = []string{
|
||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","trigger":"Application","vmstate":"HALT","gasconsumed":"22910000","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteArray","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"ByteArray","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteArray","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}}]}`,
|
||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","trigger":"Application","vmstate":"HALT","gasconsumed":"6042610","stack":[],"notifications":[{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteArray","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteArray","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}]}},{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteArray","value":"dHJhbnNmZXI="},{"type":"ByteArray","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteArray","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","trigger":"Application","vmstate":"HALT","gasconsumed":"22910000","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteString","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteString","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}}]}`,
|
||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","trigger":"Application","vmstate":"HALT","gasconsumed":"6042610","stack":[],"notifications":[{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteString","value":"Y29udHJhY3QgY2FsbA=="},{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}]}},{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x2d312f6379ead13cf62634c703091b750e7903728df2a3cf5bd96ce80b84a849","version":0,"previousblockhash":"0xb8237d34c156cac6be7b01578decf8ac8c99a62f0b6f774d622aad7be0fe189d","merkleroot":"0xf89169e89361692b71e671f13c088e84c5325015c413e8f89e7ba38efdb41287","time":1592472500006,"index":6,"nextconsensus":"Nbb1qkwcwNSBs9pAnrVVrnFbWnbWBk91U2","witnesses":[{"invocation":"DEDblVguNGXWbUswDvBfVJzBt76BJyJ0Ga6siquyjioGn4Dbr6zy1IvcLl3xN5akcejRy9e+Mr1qvpe/gkLgtW4QDEDRwPISZagMFjE/plXTnZ/gEU0IbBAAe23U29zVWteUmzRsPxF/MdzXvdffR9W0edkj17AmkWpn+5rqzH9aCOpLDECEvjgxZaRoAHEDNzp1REllLcGzMwrwSjudtzfgRglQL3g1BKerDx6cGHH73medRVkL9QVm4KzSxlywVtvhwBMrDEBuPKvzg5TtakFW2jr/bfmy1bn2FiLARlOySwaGdKRV93ozA5lVEIAvHbBlJtT4/5H8jHjbncXXMrP3OUHqebZz","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBMHOzuw=="}],"consensusdata":{"primary":0,"nonce":"0000000000000457"},"tx":[{"hash":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","size":265,"version":0,"nonce":9,"sender":"NQRLhCpAru9BjGsMwk67vdMwmzKMRgsnnN","sysfee":"0","netfee":"365210","validuntilblock":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":"CalledByEntry"}],"script":"AHsMFCBygnSvr8NvQ6Bx0yjPo+Yp2cuwDBQxboUQOQGdOd/Cw31sP+4Z/VgJhxPADAh0cmFuc2ZlcgwU2gHvYphOfQUnXEpYeyAtoLP3X+ZBYn1bUjg=","witnesses":[{"invocation":"DECwklSj3liZOJbktRtkVdUCu8U2LQlrU6Dv8NtMgd0xXbk5lXjc2p68xv6xtJXbJ4aoFMJZ9lkcNpGoeUCcaCet","verification":"DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQQqQatQ="}]}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"event_missed","params":[]}`,
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ var marshalJSONTestCases = []struct {
|
|||
},
|
||||
{
|
||||
input: Parameter{Type: ByteArrayType, Value: []byte{0x01, 0x02, 0x03}},
|
||||
result: `{"type":"ByteArray","value":"` + hexToBase64("010203") + `"}`,
|
||||
result: `{"type":"ByteString","value":"` + hexToBase64("010203") + `"}`,
|
||||
},
|
||||
{
|
||||
input: Parameter{Type: ByteArrayType},
|
||||
result: `{"type":"ByteArray","value":null}`,
|
||||
result: `{"type":"ByteString","value":null}`,
|
||||
},
|
||||
{
|
||||
input: Parameter{
|
||||
|
@ -68,8 +68,8 @@ var marshalJSONTestCases = []struct {
|
|||
}},
|
||||
},
|
||||
},
|
||||
result: `{"type":"Array","value":[{"type":"ByteArray","value":"` + hexToBase64("0102") + `"},{"type":"Array","value":[` +
|
||||
`{"type":"ByteArray","value":"` + hexToBase64("030201") + `"},{"type":"ByteArray","value":"` + hexToBase64("070809") + `"}]}]}`,
|
||||
result: `{"type":"Array","value":[{"type":"ByteString","value":"` + hexToBase64("0102") + `"},{"type":"Array","value":[` +
|
||||
`{"type":"ByteString","value":"` + hexToBase64("030201") + `"},{"type":"ByteString","value":"` + hexToBase64("070809") + `"}]}]}`,
|
||||
},
|
||||
{
|
||||
input: Parameter{
|
||||
|
@ -185,7 +185,7 @@ var unmarshalJSONTestCases = []struct {
|
|||
result: Parameter{Type: IntegerType, Value: int64(12345)},
|
||||
},
|
||||
{
|
||||
input: `{"type":"ByteArray","value":"` + hexToBase64("010203") + `"}`,
|
||||
input: `{"type":"ByteString","value":"` + hexToBase64("010203") + `"}`,
|
||||
result: Parameter{Type: ByteArrayType, Value: []byte{0x01, 0x02, 0x03}},
|
||||
},
|
||||
{
|
||||
|
@ -288,9 +288,9 @@ var unmarshalJSONTestCases = []struct {
|
|||
}
|
||||
|
||||
var unmarshalJSONErrorCases = []string{
|
||||
`{"type": "ByteArray","value":`, // incorrect JSON
|
||||
`{"type": "ByteArray","value":1}`, // incorrect Value
|
||||
`{"type": "ByteArray","value":"12^"}`, // incorrect ByteArray value
|
||||
`{"type": "ByteString","value":`, // incorrect JSON
|
||||
`{"type": "ByteString","value":1}`, // incorrect Value
|
||||
`{"type": "ByteString","value":"12^"}`, // incorrect ByteArray value
|
||||
`{"type": "String","value":`, // incorrect JSON
|
||||
`{"type": "String","value":1}`, // incorrect Value
|
||||
`{"type": "Integer","value": "nn"}`, // incorrect Integer value
|
||||
|
|
|
@ -202,7 +202,7 @@ func (i *Struct) Bool() bool { return true }
|
|||
|
||||
// TryBytes implements Item interface.
|
||||
func (i *Struct) TryBytes() ([]byte, error) {
|
||||
return nil, errors.New("can't convert Struct to ByteArray")
|
||||
return nil, errors.New("can't convert Struct to ByteString")
|
||||
}
|
||||
|
||||
// TryInteger implements Item interface.
|
||||
|
@ -288,7 +288,7 @@ func (i Null) Bool() bool { return false }
|
|||
|
||||
// TryBytes implements Item interface.
|
||||
func (i Null) TryBytes() ([]byte, error) {
|
||||
return nil, errors.New("can't convert Null to ByteArray")
|
||||
return nil, errors.New("can't convert Null to ByteString")
|
||||
}
|
||||
|
||||
// TryInteger implements Item interface.
|
||||
|
@ -484,7 +484,7 @@ func (i *ByteArray) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
func (i *ByteArray) String() string {
|
||||
return "ByteArray"
|
||||
return "ByteString"
|
||||
}
|
||||
|
||||
// Bool implements Item interface.
|
||||
|
@ -593,7 +593,7 @@ func (i *Array) Bool() bool { return true }
|
|||
|
||||
// TryBytes implements Item interface.
|
||||
func (i *Array) TryBytes() ([]byte, error) {
|
||||
return nil, errors.New("can't convert Array to ByteArray")
|
||||
return nil, errors.New("can't convert Array to ByteString")
|
||||
}
|
||||
|
||||
// TryInteger implements Item interface.
|
||||
|
@ -683,7 +683,7 @@ func (i *Map) Bool() bool { return true }
|
|||
|
||||
// TryBytes implements Item interface.
|
||||
func (i *Map) TryBytes() ([]byte, error) {
|
||||
return nil, errors.New("can't convert Map to ByteArray")
|
||||
return nil, errors.New("can't convert Map to ByteString")
|
||||
}
|
||||
|
||||
// TryInteger implements Item interface.
|
||||
|
@ -799,7 +799,7 @@ func (i *Interop) Bool() bool { return true }
|
|||
|
||||
// TryBytes implements Item interface.
|
||||
func (i *Interop) TryBytes() ([]byte, error) {
|
||||
return nil, errors.New("can't convert Interop to ByteArray")
|
||||
return nil, errors.New("can't convert Interop to ByteString")
|
||||
}
|
||||
|
||||
// TryInteger implements Item interface.
|
||||
|
@ -880,7 +880,7 @@ func (p *Pointer) Bool() bool {
|
|||
|
||||
// TryBytes implements Item interface.
|
||||
func (p *Pointer) TryBytes() ([]byte, error) {
|
||||
return nil, errors.New("can't convert Pointer to ByteArray")
|
||||
return nil, errors.New("can't convert Pointer to ByteString")
|
||||
}
|
||||
|
||||
// TryInteger implements Item interface.
|
||||
|
|
|
@ -112,7 +112,7 @@ var stringerTestCases = []struct {
|
|||
},
|
||||
{
|
||||
input: NewByteArray([]byte{}),
|
||||
result: "ByteArray",
|
||||
result: "ByteString",
|
||||
},
|
||||
{
|
||||
input: NewArray([]Item{}),
|
||||
|
|
|
@ -29,7 +29,7 @@ func (t Type) String() string {
|
|||
case IntegerT:
|
||||
return "Integer"
|
||||
case ByteArrayT:
|
||||
return "ByteArray"
|
||||
return "ByteString"
|
||||
case BufferT:
|
||||
return "Buffer"
|
||||
case ArrayT:
|
||||
|
|
Loading…
Reference in a new issue