From 52d8d58593dc6e902d0870edf4300b3a917c2c3f Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 10 Feb 2020 10:51:29 +0300 Subject: [PATCH] compiler,interop: make AppCall accept varargs --- pkg/compiler/interop_test.go | 8 +++----- pkg/interop/engine/engine.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/compiler/interop_test.go b/pkg/compiler/interop_test.go index 29831477f..4a3a65484 100644 --- a/pkg/compiler/interop_test.go +++ b/pkg/compiler/interop_test.go @@ -55,9 +55,7 @@ func TestFromAddress(t *testing.T) { func TestAppCall(t *testing.T) { srcInner := ` package foo - func Main(args []interface{}) int { - a := args[0].(int) - b := args[1].(int) + func Main(a int, b int) int { return a + b } ` @@ -109,7 +107,7 @@ func TestAppCall(t *testing.T) { func Main() int { x := 13 y := 29 - result := engine.AppCall([]byte(scriptHash), []interface{}{x, y}) + result := engine.AppCall([]byte(scriptHash), x, y) return result.(int) } ` @@ -130,7 +128,7 @@ func getAppCallScript(h string) string { func Main() int { x := 13 y := 29 - result := engine.AppCall(` + h + `, []interface{}{x, y}) + result := engine.AppCall(` + h + `, x, y) return result.(int) } ` diff --git a/pkg/interop/engine/engine.go b/pkg/interop/engine/engine.go index 3230d4a09..d094e3a43 100644 --- a/pkg/interop/engine/engine.go +++ b/pkg/interop/engine/engine.go @@ -29,6 +29,6 @@ func GetEntryScriptHash() []byte { } // AppCall executes script with specified hash using provided arguments. -func AppCall(scriptHash []byte, args []interface{}) interface{} { +func AppCall(scriptHash []byte, args ...interface{}) interface{} { return nil }