From 93530fa8fae4393ae4947bc256d79d071a3442cd Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 31 Mar 2021 13:54:53 +0300 Subject: [PATCH] core: pop all args from stack before validation checks in Notify We should match the C# behaviour. --- pkg/core/interop/runtime/engine.go | 4 ++-- pkg/core/interop/runtime/engine_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/core/interop/runtime/engine.go b/pkg/core/interop/runtime/engine.go index 95eadc05e..4735a3056 100644 --- a/pkg/core/interop/runtime/engine.go +++ b/pkg/core/interop/runtime/engine.go @@ -52,11 +52,11 @@ func GetTrigger(ic *interop.Context) error { // in neo-go the only meaningful thing to do here is to log. func Notify(ic *interop.Context) error { name := ic.VM.Estack().Pop().String() + elem := ic.VM.Estack().Pop() + args := elem.Array() if len(name) > MaxEventNameLen { return fmt.Errorf("event name must be less than %d", MaxEventNameLen) } - elem := ic.VM.Estack().Pop() - args := elem.Array() // 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. diff --git a/pkg/core/interop/runtime/engine_test.go b/pkg/core/interop/runtime/engine_test.go index 87618e00d..27a2e98f9 100644 --- a/pkg/core/interop/runtime/engine_test.go +++ b/pkg/core/interop/runtime/engine_test.go @@ -142,7 +142,7 @@ func TestNotify(t *testing.T) { return ic } t.Run("big name", func(t *testing.T) { - ic := newIC(string(make([]byte, MaxEventNameLen+1)), []byte{42}) + ic := newIC(string(make([]byte, MaxEventNameLen+1)), stackitem.NewArray([]stackitem.Item{stackitem.Null{}})) require.Error(t, Notify(ic)) }) t.Run("recursive struct", func(t *testing.T) {