diff --git a/pkg/vm/emit/emit.go b/pkg/vm/emit/emit.go index a4825e82f..37d6bd7c7 100644 --- a/pkg/vm/emit/emit.go +++ b/pkg/vm/emit/emit.go @@ -70,6 +70,8 @@ func Int(w *io.BinWriter, i int64) { func Array(w *io.BinWriter, es ...interface{}) { for i := len(es) - 1; i >= 0; i-- { switch e := es[i].(type) { + case []interface{}: + Array(w, e...) case int64: Int(w, e) case string: diff --git a/pkg/vm/emit/emit_test.go b/pkg/vm/emit/emit_test.go index 5133d7ca6..be2aad6d0 100644 --- a/pkg/vm/emit/emit_test.go +++ b/pkg/vm/emit/emit_test.go @@ -143,7 +143,7 @@ func TestBytes(t *testing.T) { func TestEmitArray(t *testing.T) { t.Run("good", func(t *testing.T) { buf := io.NewBufBinWriter() - Array(buf.BinWriter, nil, int64(1), "str", true, []byte{0xCA, 0xFE}) + Array(buf.BinWriter, []interface{}{int64(1), int64(2)}, nil, int64(1), "str", true, []byte{0xCA, 0xFE}) require.NoError(t, buf.Err) res := buf.Bytes() @@ -156,6 +156,10 @@ func TestEmitArray(t *testing.T) { assert.EqualValues(t, []byte("str"), res[7:10]) assert.EqualValues(t, opcode.PUSH1, res[10]) assert.EqualValues(t, opcode.PUSHNULL, res[11]) + assert.EqualValues(t, opcode.PUSH2, res[12]) + assert.EqualValues(t, opcode.PUSH1, res[13]) + assert.EqualValues(t, opcode.PUSH2, res[14]) + assert.EqualValues(t, opcode.PACK, res[15]) }) t.Run("empty", func(t *testing.T) {