From a3285eae04e673f7443ded0f9ebf4c8b1dace659 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 25 May 2022 13:20:21 +0300 Subject: [PATCH] vm: stringify InteropInterface stackitem type as `InteropInterface` --- pkg/vm/stackitem/item.go | 2 +- pkg/vm/stackitem/item_test.go | 2 +- pkg/vm/stackitem/json.go | 2 +- pkg/vm/stackitem/json_test.go | 4 ++-- pkg/vm/stackitem/type.go | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/vm/stackitem/item.go b/pkg/vm/stackitem/item.go index 18afb7349..649e56e93 100644 --- a/pkg/vm/stackitem/item.go +++ b/pkg/vm/stackitem/item.go @@ -910,7 +910,7 @@ func (i *Interop) Value() interface{} { // String implements stringer interface. func (i *Interop) String() string { - return "Interop" + return "InteropInterface" } // Dup implements the Item interface. diff --git a/pkg/vm/stackitem/item_test.go b/pkg/vm/stackitem/item_test.go index 72920c8e2..8f87038eb 100644 --- a/pkg/vm/stackitem/item_test.go +++ b/pkg/vm/stackitem/item_test.go @@ -126,7 +126,7 @@ var stringerTestCases = []struct { }, { input: NewInterop(nil), - result: "Interop", + result: "InteropInterface", }, { input: NewPointer(0, nil), diff --git a/pkg/vm/stackitem/json.go b/pkg/vm/stackitem/json.go index 89540b51d..70b5074e4 100644 --- a/pkg/vm/stackitem/json.go +++ b/pkg/vm/stackitem/json.go @@ -299,7 +299,7 @@ func toJSONWithTypes(data []byte, item Item, seen map[Item]sliceNoPointer) ([]by case Null: val = `{"type":"Any"}` case *Interop: - val = `{"type":"Interop"}` + val = `{"type":"InteropInterface"}` default: val = `{"type":"` + item.Type().String() + `","value":` hasValue = true diff --git a/pkg/vm/stackitem/json_test.go b/pkg/vm/stackitem/json_test.go index fcc35f477..c68db70f0 100644 --- a/pkg/vm/stackitem/json_test.go +++ b/pkg/vm/stackitem/json_test.go @@ -235,7 +235,7 @@ func TestToJSONWithTypes(t *testing.T) { `{"type":"Map","value":[{"key":{"type":"Integer","value":"42"},` + `"value":{"type":"Boolean","value":false}}]}`}, {"Interop", NewInterop(nil), - `{"type":"Interop"}`}, + `{"type":"InteropInterface"}`}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { @@ -385,7 +385,7 @@ func TestFromJSONWithTypes(t *testing.T) { item Item }{ {"Pointer", `{"type":"Pointer","value":3}`, NewPointer(3, nil)}, - {"Interop", `{"type":"Interop"}`, NewInterop(nil)}, + {"Interop", `{"type":"InteropInterface"}`, NewInterop(nil)}, {"Null", `{"type":"Any"}`, Null{}}, {"Array", `{"type":"Array","value":[{"type":"Any"}]}`, NewArray([]Item{Null{}})}, } diff --git a/pkg/vm/stackitem/type.go b/pkg/vm/stackitem/type.go index 67f090e41..9f3e4ced8 100644 --- a/pkg/vm/stackitem/type.go +++ b/pkg/vm/stackitem/type.go @@ -45,7 +45,7 @@ func (t Type) String() string { case MapT: return "Map" case InteropT: - return "Interop" + return "InteropInterface" default: return "INVALID" } @@ -82,7 +82,7 @@ func FromString(s string) (Type, error) { return StructT, nil case "Map": return MapT, nil - case "Interop": + case "InteropInterface": return InteropT, nil default: return 0xFF, ErrInvalidType