From 0de949b575afe3d81f5dfe5aaaef31baf645ed42 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 6 Jul 2021 19:56:23 +0300 Subject: [PATCH] stackitem: remove Item/StackItem from function names They're useless in a package named 'stackitem', make this package a bit more user-friendly. --- pkg/core/interop/runtime/engine.go | 2 +- pkg/core/interop/storage/find.go | 2 +- pkg/core/interop_system_test.go | 6 +-- pkg/core/native/native_neo.go | 2 +- pkg/core/native/native_neo_candidate.go | 4 +- pkg/core/native/neo_types.go | 4 +- pkg/core/native/oracle.go | 4 +- pkg/core/native/oracle_types.go | 8 ++-- pkg/core/native/oracle_types_test.go | 2 +- pkg/core/native/std.go | 4 +- pkg/core/native/std_test.go | 4 +- pkg/core/native_management_test.go | 8 ++-- pkg/core/native_oracle_test.go | 2 +- pkg/core/state/contract.go | 4 +- pkg/core/state/native_state.go | 8 ++-- pkg/core/state/notification_event.go | 8 ++-- pkg/core/state/notification_event_test.go | 2 +- pkg/core/state/oracle.go | 4 +- pkg/core/state/oracle_test.go | 4 +- pkg/vm/stackitem/serialization.go | 45 ++++++++++++----------- pkg/vm/stackitem/serialization_test.go | 4 +- 21 files changed, 67 insertions(+), 64 deletions(-) diff --git a/pkg/core/interop/runtime/engine.go b/pkg/core/interop/runtime/engine.go index 8bb3f8e19..fe25c8b77 100644 --- a/pkg/core/interop/runtime/engine.go +++ b/pkg/core/interop/runtime/engine.go @@ -61,7 +61,7 @@ func Notify(ic *interop.Context) error { // But it has to be serializable, otherwise we either have some broken // (recursive) structure inside or an interop item that can't be used // outside of the interop subsystem anyway. - bytes, err := stackitem.SerializeItem(elem.Item()) + bytes, err := stackitem.Serialize(elem.Item()) if err != nil { return fmt.Errorf("bad notification: %w", err) } diff --git a/pkg/core/interop/storage/find.go b/pkg/core/interop/storage/find.go index a969e1077..045c9290f 100644 --- a/pkg/core/interop/storage/find.go +++ b/pkg/core/interop/storage/find.go @@ -57,7 +57,7 @@ func (s *Iterator) Value() stackitem.Item { if s.opts&FindDeserialize != 0 { bs := s.m[s.index].Value.Value().([]byte) var err error - value, err = stackitem.DeserializeItem(bs) + value, err = stackitem.Deserialize(bs) if err != nil { panic(err) } diff --git a/pkg/core/interop_system_test.go b/pkg/core/interop_system_test.go index 298bf29e9..a64b45aa1 100644 --- a/pkg/core/interop_system_test.go +++ b/pkg/core/interop_system_test.go @@ -266,11 +266,11 @@ func TestStorageFind(t *testing.T) { stackitem.NewByteArray([]byte("second")), stackitem.Null{}, } - rawArr, err := stackitem.SerializeItem(stackitem.NewArray(arr)) + rawArr, err := stackitem.Serialize(stackitem.NewArray(arr)) require.NoError(t, err) - rawArr0, err := stackitem.SerializeItem(stackitem.NewArray(arr[:0])) + rawArr0, err := stackitem.Serialize(stackitem.NewArray(arr[:0])) require.NoError(t, err) - rawArr1, err := stackitem.SerializeItem(stackitem.NewArray(arr[:1])) + rawArr1, err := stackitem.Serialize(stackitem.NewArray(arr[:1])) require.NoError(t, err) skeys := [][]byte{{0x01, 0x02}, {0x02, 0x01}, {0x01, 0x01}, diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index b3ae87b85..dadeaee35 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -904,7 +904,7 @@ func (n *NEO) getAccountState(ic *interop.Context, args []stackitem.Item) stacki } r := io.NewBinReaderFromBuf(si) - item := stackitem.DecodeBinaryStackItem(r) + item := stackitem.DecodeBinary(r) if r.Err != nil { panic(r.Err) // no errors are expected but we better be sure } diff --git a/pkg/core/native/native_neo_candidate.go b/pkg/core/native/native_neo_candidate.go index 0fa014eb6..a1a7bb44f 100644 --- a/pkg/core/native/native_neo_candidate.go +++ b/pkg/core/native/native_neo_candidate.go @@ -15,14 +15,14 @@ type candidate struct { // Bytes marshals c to byte array. func (c *candidate) Bytes() []byte { w := io.NewBufBinWriter() - stackitem.EncodeBinaryStackItem(c.toStackItem(), w.BinWriter) + stackitem.EncodeBinary(c.toStackItem(), w.BinWriter) return w.Bytes() } // FromBytes unmarshals candidate from byte array. func (c *candidate) FromBytes(data []byte) *candidate { r := io.NewBinReaderFromBuf(data) - item := stackitem.DecodeBinaryStackItem(r) + item := stackitem.DecodeBinary(r) if r.Err != nil { panic(r.Err) } diff --git a/pkg/core/native/neo_types.go b/pkg/core/native/neo_types.go index aeefda5b9..15dcf1e97 100644 --- a/pkg/core/native/neo_types.go +++ b/pkg/core/native/neo_types.go @@ -86,7 +86,7 @@ func (k *keysWithVotes) fromStackItem(item stackitem.Item) error { func (k keysWithVotes) Bytes() []byte { var it = k.toStackItem() var w = io.NewBufBinWriter() - stackitem.EncodeBinaryStackItem(it, w.BinWriter) + stackitem.EncodeBinary(it, w.BinWriter) if w.Err != nil { panic(w.Err) } @@ -96,7 +96,7 @@ func (k keysWithVotes) Bytes() []byte { // DecodeBytes deserializes keys and votes slice. func (k *keysWithVotes) DecodeBytes(data []byte) error { var r = io.NewBinReaderFromBuf(data) - var it = stackitem.DecodeBinaryStackItem(r) + var it = stackitem.DecodeBinary(r) if r.Err != nil { return r.Err } diff --git a/pkg/core/native/oracle.go b/pkg/core/native/oracle.go index b6deb469c..7c500f6cf 100644 --- a/pkg/core/native/oracle.go +++ b/pkg/core/native/oracle.go @@ -278,7 +278,7 @@ func (o *Oracle) FinishInternal(ic *interop.Context) error { }) r := io.NewBinReaderFromBuf(req.UserData) - userData := stackitem.DecodeBinaryStackItem(r) + userData := stackitem.DecodeBinary(r) args := []stackitem.Item{ stackitem.Make(req.URL), stackitem.Make(userData), @@ -358,7 +358,7 @@ func (o *Oracle) RequestInternal(ic *interop.Context, url string, filter *string } w := io.NewBufBinWriter() - stackitem.EncodeBinaryStackItem(userData, w.BinWriter) + stackitem.EncodeBinary(userData, w.BinWriter) if w.Err != nil { return w.Err } diff --git a/pkg/core/native/oracle_types.go b/pkg/core/native/oracle_types.go index fc6c90145..985897e72 100644 --- a/pkg/core/native/oracle_types.go +++ b/pkg/core/native/oracle_types.go @@ -25,12 +25,12 @@ func (l IDList) Bytes() []byte { // EncodeBinary implements io.Serializable. func (l IDList) EncodeBinary(w *io.BinWriter) { - stackitem.EncodeBinaryStackItem(l.toStackItem(), w) + stackitem.EncodeBinary(l.toStackItem(), w) } // DecodeBinary implements io.Serializable. func (l *IDList) DecodeBinary(r *io.BinReader) { - item := stackitem.DecodeBinaryStackItem(r) + item := stackitem.DecodeBinary(r) if r.Err != nil || item == nil { return } @@ -84,12 +84,12 @@ func (l NodeList) Bytes() []byte { // EncodeBinary implements io.Serializable. func (l NodeList) EncodeBinary(w *io.BinWriter) { - stackitem.EncodeBinaryStackItem(l.toStackItem(), w) + stackitem.EncodeBinary(l.toStackItem(), w) } // DecodeBinary implements io.Serializable. func (l *NodeList) DecodeBinary(r *io.BinReader) { - item := stackitem.DecodeBinaryStackItem(r) + item := stackitem.DecodeBinary(r) if r.Err != nil || item == nil { return } diff --git a/pkg/core/native/oracle_types_test.go b/pkg/core/native/oracle_types_test.go index 78acf7bf2..c58323dd9 100644 --- a/pkg/core/native/oracle_types_test.go +++ b/pkg/core/native/oracle_types_test.go @@ -14,7 +14,7 @@ func getInvalidTestFunc(actual io.Serializable, value interface{}) func(t *testi return func(t *testing.T) { w := io.NewBufBinWriter() it := stackitem.Make(value) - stackitem.EncodeBinaryStackItem(it, w.BinWriter) + stackitem.EncodeBinary(it, w.BinWriter) require.NoError(t, w.Err) require.Error(t, testserdes.DecodeBinary(w.Bytes(), actual)) } diff --git a/pkg/core/native/std.go b/pkg/core/native/std.go index d27be752e..f2e614b0a 100644 --- a/pkg/core/native/std.go +++ b/pkg/core/native/std.go @@ -160,7 +160,7 @@ func newStd() *Std { } func (s *Std) serialize(_ *interop.Context, args []stackitem.Item) stackitem.Item { - data, err := stackitem.SerializeItem(args[0]) + data, err := stackitem.Serialize(args[0]) if err != nil { panic(err) } @@ -177,7 +177,7 @@ func (s *Std) deserialize(_ *interop.Context, args []stackitem.Item) stackitem.I panic(err) } - item, err := stackitem.DeserializeItem(data) + item, err := stackitem.Deserialize(data) if err != nil { panic(err) } diff --git a/pkg/core/native/std_test.go b/pkg/core/native/std_test.go index ce16eb01d..2558b5f2d 100644 --- a/pkg/core/native/std_test.go +++ b/pkg/core/native/std_test.go @@ -276,7 +276,7 @@ func TestStdLibSerialize(t *testing.T) { }) w := io.NewBufBinWriter() - stackitem.EncodeBinaryStackItem(stackitem.Make(42), w.BinWriter) + stackitem.EncodeBinary(stackitem.Make(42), w.BinWriter) require.NoError(t, w.Err) encoded := w.Bytes() @@ -368,7 +368,7 @@ func TestStdLibSerializeDeserialize(t *testing.T) { }) }) t.Run("Deserialize unknown", func(t *testing.T) { - data, err := stackitem.SerializeItem(stackitem.NewBigInteger(big.NewInt(123))) + data, err := stackitem.Serialize(stackitem.NewBigInteger(big.NewInt(123))) require.NoError(t, err) data[0] = 0xFF diff --git a/pkg/core/native_management_test.go b/pkg/core/native_management_test.go index 355a57e37..57ec4c54e 100644 --- a/pkg/core/native_management_test.go +++ b/pkg/core/native_management_test.go @@ -94,7 +94,7 @@ func TestContractDeployAndUpdateWithParameter(t *testing.T) { res, err := invokeContractMethod(bc, 1_00000000, cs1.Hash, "getValue") require.NoError(t, err) require.Equal(t, 1, len(res.Stack)) - item, err := stackitem.DeserializeItem(res.Stack[0].Value().([]byte)) + item, err := stackitem.Deserialize(res.Stack[0].Value().([]byte)) require.NoError(t, err) expected := []stackitem.Item{stackitem.Make("create"), stackitem.Make(42)} require.Equal(t, stackitem.NewArray(expected), item) @@ -114,7 +114,7 @@ func TestContractDeployAndUpdateWithParameter(t *testing.T) { res, err := invokeContractMethod(bc, 1_00000000, cs1.Hash, "getValue") require.NoError(t, err) require.Equal(t, 1, len(res.Stack)) - item, err := stackitem.DeserializeItem(res.Stack[0].Value().([]byte)) + item, err := stackitem.Deserialize(res.Stack[0].Value().([]byte)) require.NoError(t, err) expected := []stackitem.Item{stackitem.Make("update"), stackitem.Make("new data")} require.Equal(t, stackitem.NewArray(expected), item) @@ -259,7 +259,7 @@ func TestContractDeploy(t *testing.T) { res, err := invokeContractMethod(bc, 1_00000000, cs1.Hash, "getValue") require.NoError(t, err) require.Equal(t, 1, len(res.Stack)) - item, err := stackitem.DeserializeItem(res.Stack[0].Value().([]byte)) + item, err := stackitem.Deserialize(res.Stack[0].Value().([]byte)) require.NoError(t, err) expected := []stackitem.Item{stackitem.Make("create"), stackitem.Null{}} require.Equal(t, stackitem.NewArray(expected), item) @@ -466,7 +466,7 @@ func TestContractUpdate(t *testing.T) { res, err := invokeContractMethod(bc, 1_00000000, cs1.Hash, "getValue") require.NoError(t, err) require.Equal(t, 1, len(res.Stack)) - item, err := stackitem.DeserializeItem(res.Stack[0].Value().([]byte)) + item, err := stackitem.Deserialize(res.Stack[0].Value().([]byte)) require.NoError(t, err) expected := []stackitem.Item{stackitem.Make("update"), stackitem.Null{}} require.Equal(t, stackitem.NewArray(expected), item) diff --git a/pkg/core/native_oracle_test.go b/pkg/core/native_oracle_test.go index 3c56fb00a..660eb1ba7 100644 --- a/pkg/core/native_oracle_test.go +++ b/pkg/core/native_oracle_test.go @@ -183,7 +183,7 @@ func TestOracle_Request(t *testing.T) { si := ic.DAO.GetStorageItem(cs.ID, []byte("lastOracleResponse")) require.NotNil(t, si) - item, err := stackitem.DeserializeItem(si) + item, err := stackitem.Deserialize(si) require.NoError(t, err) arr, ok := item.Value().([]stackitem.Item) require.True(t, ok) diff --git a/pkg/core/state/contract.go b/pkg/core/state/contract.go index 3c6da196b..e6ee4e873 100644 --- a/pkg/core/state/contract.go +++ b/pkg/core/state/contract.go @@ -37,7 +37,7 @@ type NativeContract struct { // DecodeBinary implements Serializable interface. func (c *Contract) DecodeBinary(r *io.BinReader) { - si := stackitem.DecodeBinaryStackItem(r) + si := stackitem.DecodeBinary(r) if r.Err != nil { return } @@ -51,7 +51,7 @@ func (c *Contract) EncodeBinary(w *io.BinWriter) { w.Err = err return } - stackitem.EncodeBinaryStackItem(si, w) + stackitem.EncodeBinary(si, w) } // ToStackItem converts state.Contract to stackitem.Item. diff --git a/pkg/core/state/native_state.go b/pkg/core/state/native_state.go index 4b45239ab..75baee89d 100644 --- a/pkg/core/state/native_state.go +++ b/pkg/core/state/native_state.go @@ -58,12 +58,12 @@ func (s *NEP17BalanceState) fromStackItem(item stackitem.Item) { // EncodeBinary implements io.Serializable interface. func (s *NEP17BalanceState) EncodeBinary(w *io.BinWriter) { si := s.toStackItem() - stackitem.EncodeBinaryStackItem(si, w) + stackitem.EncodeBinary(si, w) } // DecodeBinary implements io.Serializable interface. func (s *NEP17BalanceState) DecodeBinary(r *io.BinReader) { - si := stackitem.DecodeBinaryStackItem(r) + si := stackitem.DecodeBinary(r) if r.Err != nil { return } @@ -98,12 +98,12 @@ func (s *NEOBalanceState) Bytes() []byte { // EncodeBinary implements io.Serializable interface. func (s *NEOBalanceState) EncodeBinary(w *io.BinWriter) { si := s.toStackItem() - stackitem.EncodeBinaryStackItem(si, w) + stackitem.EncodeBinary(si, w) } // DecodeBinary implements io.Serializable interface. func (s *NEOBalanceState) DecodeBinary(r *io.BinReader) { - si := stackitem.DecodeBinaryStackItem(r) + si := stackitem.DecodeBinary(r) if r.Err != nil { return } diff --git a/pkg/core/state/notification_event.go b/pkg/core/state/notification_event.go index a7c032b76..193fc8667 100644 --- a/pkg/core/state/notification_event.go +++ b/pkg/core/state/notification_event.go @@ -31,14 +31,14 @@ type AppExecResult struct { func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter) { ne.ScriptHash.EncodeBinary(w) w.WriteString(ne.Name) - stackitem.EncodeBinaryStackItem(ne.Item, w) + stackitem.EncodeBinary(ne.Item, w) } // DecodeBinary implements the Serializable interface. func (ne *NotificationEvent) DecodeBinary(r *io.BinReader) { ne.ScriptHash.DecodeBinary(r) ne.Name = r.ReadString() - item := stackitem.DecodeBinaryStackItem(r) + item := stackitem.DecodeBinary(r) if r.Err != nil { return } @@ -59,7 +59,7 @@ func (aer *AppExecResult) EncodeBinary(w *io.BinWriter) { // Stack items are expected to be marshaled one by one. w.WriteVarUint(uint64(len(aer.Stack))) for _, it := range aer.Stack { - stackitem.EncodeBinaryStackItemAppExec(it, w) + stackitem.EncodeBinaryProtected(it, w) } w.WriteArray(aer.Events) w.WriteVarBytes([]byte(aer.FaultException)) @@ -80,7 +80,7 @@ func (aer *AppExecResult) DecodeBinary(r *io.BinReader) { } arr := make([]stackitem.Item, sz) for i := 0; i < int(sz); i++ { - arr[i] = stackitem.DecodeBinaryStackItemAppExec(r) + arr[i] = stackitem.DecodeBinaryProtected(r) if r.Err != nil { return } diff --git a/pkg/core/state/notification_event_test.go b/pkg/core/state/notification_event_test.go index 2429b7c81..55e36f3aa 100644 --- a/pkg/core/state/notification_event_test.go +++ b/pkg/core/state/notification_event_test.go @@ -77,7 +77,7 @@ func TestEncodeDecodeAppExecResult(t *testing.T) { w.WriteB(byte(aer.Trigger)) w.WriteB(byte(aer.VMState)) w.WriteU64LE(uint64(aer.GasConsumed)) - stackitem.EncodeBinaryStackItem(stackitem.NewBool(true), w.BinWriter) + stackitem.EncodeBinary(stackitem.NewBool(true), w.BinWriter) require.NoError(t, w.Err) require.Error(t, testserdes.DecodeBinary(w.Bytes(), new(AppExecResult))) }) diff --git a/pkg/core/state/oracle.go b/pkg/core/state/oracle.go index ac8fa114d..96efde901 100644 --- a/pkg/core/state/oracle.go +++ b/pkg/core/state/oracle.go @@ -30,12 +30,12 @@ func (o *OracleRequest) Bytes() []byte { // EncodeBinary implements io.Serializable. func (o *OracleRequest) EncodeBinary(w *io.BinWriter) { - stackitem.EncodeBinaryStackItem(o.toStackItem(), w) + stackitem.EncodeBinary(o.toStackItem(), w) } // DecodeBinary implements io.Serializable. func (o *OracleRequest) DecodeBinary(r *io.BinReader) { - item := stackitem.DecodeBinaryStackItem(r) + item := stackitem.DecodeBinary(r) if r.Err != nil || item == nil { return } diff --git a/pkg/core/state/oracle_test.go b/pkg/core/state/oracle_test.go index dc0a9ed12..bb17ee6bc 100644 --- a/pkg/core/state/oracle_test.go +++ b/pkg/core/state/oracle_test.go @@ -34,7 +34,7 @@ func TestOracleRequest_EncodeBinary(t *testing.T) { t.Run("NotArray", func(t *testing.T) { w.Reset() it := stackitem.NewByteArray([]byte{}) - stackitem.EncodeBinaryStackItem(it, w.BinWriter) + stackitem.EncodeBinary(it, w.BinWriter) require.Error(t, testserdes.DecodeBinary(w.Bytes(), new(OracleRequest))) }) t.Run("NotStackItem", func(t *testing.T) { @@ -57,7 +57,7 @@ func TestOracleRequest_EncodeBinary(t *testing.T) { w.Reset() before := items[i] items[i] = elem - stackitem.EncodeBinaryStackItem(arrItem, w.BinWriter) + stackitem.EncodeBinary(arrItem, w.BinWriter) items[i] = before require.Error(t, testserdes.DecodeBinary(w.Bytes(), new(OracleRequest))) } diff --git a/pkg/vm/stackitem/serialization.go b/pkg/vm/stackitem/serialization.go index f121a3659..f668522a6 100644 --- a/pkg/vm/stackitem/serialization.go +++ b/pkg/vm/stackitem/serialization.go @@ -17,8 +17,8 @@ type serContext struct { seen map[Item]bool } -// SerializeItem encodes given Item into the byte slice. -func SerializeItem(item Item) ([]byte, error) { +// Serialize encodes given Item into the byte slice. +func Serialize(item Item) ([]byte, error) { w := io.NewBufBinWriter() sc := serContext{ BinWriter: w.BinWriter, @@ -33,10 +33,10 @@ func SerializeItem(item Item) ([]byte, error) { return w.Bytes(), nil } -// EncodeBinaryStackItem encodes given Item into the given BinWriter. It's +// EncodeBinary encodes given Item into the given BinWriter. It's // similar to io.Serializable's EncodeBinary, but works with Item // interface. -func EncodeBinaryStackItem(item Item, w *io.BinWriter) { +func EncodeBinary(item Item, w *io.BinWriter) { sc := serContext{ BinWriter: w, allowInvalid: false, @@ -45,9 +45,12 @@ func EncodeBinaryStackItem(item Item, w *io.BinWriter) { sc.serialize(item) } -// EncodeBinaryStackItemAppExec encodes given Item into the given BinWriter. It's -// similar to EncodeBinaryStackItem but allows to encode interop (only type, value is lost). -func EncodeBinaryStackItemAppExec(item Item, w *io.BinWriter) { +// EncodeBinaryProtected encodes given Item into the given BinWriter. It's +// similar to EncodeBinary but allows to encode interop items (only type, +// value is lost) and doesn't return any errors in w, instead if error +// (like recursive array) is encountered it just writes special InvalidT +// type of element to w. +func EncodeBinaryProtected(item Item, w *io.BinWriter) { bw := io.NewBufBinWriter() sc := serContext{ BinWriter: bw.BinWriter, @@ -132,31 +135,31 @@ func (w *serContext) serialize(item Item) { } } -// DeserializeItem decodes Item from the given byte slice. -func DeserializeItem(data []byte) (Item, error) { +// Deserialize decodes Item from the given byte slice. +func Deserialize(data []byte) (Item, error) { r := io.NewBinReaderFromBuf(data) - item := DecodeBinaryStackItem(r) + item := DecodeBinary(r) if r.Err != nil { return nil, r.Err } return item, nil } -// DecodeBinaryStackItem decodes previously serialized Item from the given +// DecodeBinary decodes previously serialized Item from the given // reader. It's similar to the io.Serializable's DecodeBinary(), but implemented // as a function because Item itself is an interface. Caveat: always check // reader's error value before using the returned Item. -func DecodeBinaryStackItem(r *io.BinReader) Item { - return decodeBinaryStackItem(r, false) +func DecodeBinary(r *io.BinReader) Item { + return decodeBinary(r, false) } -// DecodeBinaryStackItemAppExec is similar to DecodeBinaryStackItem -// but allows Interop values to be present. -func DecodeBinaryStackItemAppExec(r *io.BinReader) Item { - return decodeBinaryStackItem(r, true) +// DecodeBinaryProtected is similar to DecodeBinary but allows Interop and +// Invalid values to be present (making it symmetric to EncodeBinaryProtected). +func DecodeBinaryProtected(r *io.BinReader) Item { + return decodeBinary(r, true) } -func decodeBinaryStackItem(r *io.BinReader, allowInvalid bool) Item { +func decodeBinary(r *io.BinReader, allowInvalid bool) Item { var t = Type(r.ReadB()) if r.Err != nil { return nil @@ -180,7 +183,7 @@ func decodeBinaryStackItem(r *io.BinReader, allowInvalid bool) Item { size := int(r.ReadVarUint()) arr := make([]Item, size) for i := 0; i < size; i++ { - arr[i] = DecodeBinaryStackItem(r) + arr[i] = DecodeBinary(r) } if t == ArrayT { @@ -191,8 +194,8 @@ func decodeBinaryStackItem(r *io.BinReader, allowInvalid bool) Item { size := int(r.ReadVarUint()) m := NewMap() for i := 0; i < size; i++ { - key := DecodeBinaryStackItem(r) - value := DecodeBinaryStackItem(r) + key := DecodeBinary(r) + value := DecodeBinary(r) if r.Err != nil { break } diff --git a/pkg/vm/stackitem/serialization_test.go b/pkg/vm/stackitem/serialization_test.go index 26000a94a..f3d58aa96 100644 --- a/pkg/vm/stackitem/serialization_test.go +++ b/pkg/vm/stackitem/serialization_test.go @@ -13,9 +13,9 @@ func TestSerializationMaxErr(t *testing.T) { arr := []Item{item, item.Dup()} aitem := Make(arr) - _, err := SerializeItem(item) + _, err := Serialize(item) require.NoError(t, err) - _, err = SerializeItem(aitem) + _, err = Serialize(aitem) require.Error(t, err) }