diff --git a/pkg/compiler/interop_test.go b/pkg/compiler/interop_test.go index 875fb56fb..95c2a0d68 100644 --- a/pkg/compiler/interop_test.go +++ b/pkg/compiler/interop_test.go @@ -18,6 +18,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" + "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/base58" @@ -247,6 +248,35 @@ func TestAssertMsg(t *testing.T) { require.True(t, strings.Contains(err.Error(), "ASSERTMSG is executed with false result. Reason: some message"), err) } +func TestCurrentSigners(t *testing.T) { + bc, acc := chain.NewSingle(t) + e := neotest.NewExecutor(t, bc, acc, acc) + src := `package foo + import ( + "github.com/nspcc-dev/neo-go/pkg/interop/native/ledger" + "github.com/nspcc-dev/neo-go/pkg/interop/runtime" + ) + func Main() []ledger.TransactionSigner { + return runtime.CurrentSigners() + }` + ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"}) + e.DeployContract(t, ctr, nil) + c := e.CommitteeInvoker(ctr.Hash) + + t.Run("non-empty", func(t *testing.T) { + expected := stackitem.NewArray([]stackitem.Item{ + stackitem.NewArray([]stackitem.Item{ + stackitem.NewByteArray(e.CommitteeHash.BytesBE()), + stackitem.NewBigInteger(big.NewInt(int64(transaction.Global))), + stackitem.NewArray([]stackitem.Item{}), + stackitem.NewArray([]stackitem.Item{}), + stackitem.NewArray([]stackitem.Item{}), + }), + }) + c.Invoke(t, expected, "main") + }) +} + func spawnVM(t *testing.T, ic *interop.Context, src string) *vm.VM { b, di, err := compiler.CompileWithOptions("foo.go", strings.NewReader(src), nil) require.NoError(t, err) diff --git a/pkg/compiler/syscall_test.go b/pkg/compiler/syscall_test.go index 466271343..1358e02cb 100644 --- a/pkg/compiler/syscall_test.go +++ b/pkg/compiler/syscall_test.go @@ -73,6 +73,7 @@ func TestSyscallExecution(t *testing.T) { "iterator.Value": {interopnames.SystemIteratorValue, []string{"iterator.Iterator{}"}, false}, "runtime.BurnGas": {interopnames.SystemRuntimeBurnGas, []string{"1"}, true}, "runtime.CheckWitness": {interopnames.SystemRuntimeCheckWitness, []string{b}, false}, + "runtime.CurrentSigners": {interopnames.SystemRuntimeCurrentSigners, nil, false}, "runtime.GasLeft": {interopnames.SystemRuntimeGasLeft, nil, false}, "runtime.GetAddressVersion": {interopnames.SystemRuntimeGetAddressVersion, nil, false}, "runtime.GetCallingScriptHash": {interopnames.SystemRuntimeGetCallingScriptHash, nil, false},