compiler: make Notify accept varargs

This commit is contained in:
Evgenii Stratonikov 2020-04-05 18:05:40 +03:00
parent c0b5271386
commit efad66aee1
3 changed files with 46 additions and 3 deletions

View file

@ -2,6 +2,10 @@ package compiler_test
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestStoragePutGet(t *testing.T) {
@ -20,3 +24,24 @@ func TestStoragePutGet(t *testing.T) {
`
eval(t, src, []byte("foo"))
}
func TestNotify(t *testing.T) {
src := `package foo
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
func Main(arg int) {
runtime.Notify(arg, "sum", arg+1)
runtime.Notify()
runtime.Notify("single")
}`
v, s := vmAndCompileInterop(t, src)
v.Estack().PushVal(11)
require.NoError(t, v.Run())
require.Equal(t, 3, len(s.events))
exp0 := []vm.StackItem{vm.NewBigIntegerItem(11), vm.NewByteArrayItem([]byte("sum")), vm.NewBigIntegerItem(12)}
assert.Equal(t, exp0, s.events[0].Value())
assert.Equal(t, []vm.StackItem{}, s.events[1].Value())
assert.Equal(t, []vm.StackItem{vm.NewByteArrayItem([]byte("single"))}, s.events[2].Value())
}