Documentation
¶
Overview ¶
Package evmtest provides named-entry fixtures for compiler and binding tests.
Index ¶
- func Callback(vm *evm.VM, v values.Value, in, out []values.Value) error
- type Session
- func (s *Session) Reset() error
- func (s *Session) Run(ctx context.Context, name string, in, out []values.Value) error
- func (s *Session) RunFunction(ctx context.Context, fn *evm.Callable, in, out []values.Value) error
- func (s *Session) RunFunctionWithBudget(ctx context.Context, fn *evm.Callable, in, out []values.Value, l evm.Limits) error
- func (s *Session) RunNative(ctx context.Context, fn evm.Native, l evm.Limits) error
- func (s *Session) RunWithBudget(ctx context.Context, name string, in, out []values.Value, l evm.Limits) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Session ¶
Session owns a VM and test limits for repeated guest calls. Release it when the test is done.
func (*Session) Reset ¶
Reset releases the current VM and acquires another for the same program and context.
func (*Session) RunFunction ¶
RunFunction calls a resolved entry with the session's test limits.
func (*Session) RunFunctionWithBudget ¶
func (s *Session) RunFunctionWithBudget(ctx context.Context, fn *evm.Callable, in, out []values.Value, l evm.Limits) error
RunFunctionWithBudget calls a resolved entry with separate input and output slices. On failure, out is left untouched.
func (*Session) RunWithBudget ¶
func (s *Session) RunWithBudget(ctx context.Context, name string, in, out []values.Value, l evm.Limits) error
RunWithBudget invokes a named entry with per-call limits and tester defaults.
Example ¶
package main
import (
"context"
"errors"
"fmt"
"github.com/andreyvit/evm"
"github.com/andreyvit/evm/evmcompiler"
"github.com/andreyvit/evm/evmtest"
)
func main() {
module, err := evmcompiler.Compile("loop.go", "func Loop() { for {} }")
if err != nil {
panic(err)
}
program, err := evm.Link(module)
if err != nil {
panic(err)
}
session := evmtest.New(program)
defer session.Release()
err = session.RunWithBudget(context.Background(), "Loop", nil, nil, evm.Limits{Steps: 100})
fmt.Println(errors.Is(err, evm.ErrSteps))
}
Output: true