test

package module
v0.0.0-...-d29c747 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrettyPrintResult

func PrettyPrintResult(funcName string, err error) string

func PrettyPrintResults

func PrettyPrintResults(results Results) string

PrettyPrintResults is a utility function to pretty print the test results.

Types

type EmulatorBackend

type EmulatorBackend struct {
	// contains filtered or unexported fields
}

EmulatorBackend is the emulator-backed implementation of the interpreter.TestFramework.

func NewEmulatorBackend

func NewEmulatorBackend(fileResolver FileResolver) *EmulatorBackend

func (*EmulatorBackend) AddTransaction

func (e *EmulatorBackend) AddTransaction(
	code string,
	authorizers []common.Address,
	signers []*stdlib.Account,
	args []interpreter.Value,
) error

func (*EmulatorBackend) CommitBlock

func (e *EmulatorBackend) CommitBlock() error

func (EmulatorBackend) CreateAccount

func (e EmulatorBackend) CreateAccount() (*stdlib.Account, error)

func (*EmulatorBackend) DeployContract

func (e *EmulatorBackend) DeployContract(
	name string,
	code string,
	account *stdlib.Account,
	args []interpreter.Value,
) error

func (*EmulatorBackend) ExecuteNextTransaction

func (e *EmulatorBackend) ExecuteNextTransaction() *stdlib.TransactionResult

func (*EmulatorBackend) ReadFile

func (e *EmulatorBackend) ReadFile(path string) (string, error)

func (*EmulatorBackend) RunScript

func (e *EmulatorBackend) RunScript(code string, args []interpreter.Value) *stdlib.ScriptResult

func (*EmulatorBackend) UseConfiguration

func (e *EmulatorBackend) UseConfiguration(configuration *stdlib.Configuration)

type FileResolver

type FileResolver func(path string) (string, error)

FileResolver is used to resolve and get local files. Returns the content of the file as a string. Must be provided by the user of the TestRunner.

type FileResolverNotProvidedError

type FileResolverNotProvidedError struct {
	Err error
}

FileResolverNotProvidedError is thrown if the file resolver is not set in the TestRunner, when running tests.

func (FileResolverNotProvidedError) Error

func (FileResolverNotProvidedError) Unwrap

type ImportResolver

type ImportResolver func(location common.Location) (string, error)

ImportResolver is used to resolve and get the source code for imports. Must be provided by the user of the TestRunner.

type ImportResolverNotProvidedError

type ImportResolverNotProvidedError struct {
	Err error
}

ImportResolverNotProvidedError is thrown if the import resolver is not set in the TestRunner, when running tests.

func (ImportResolverNotProvidedError) Error

func (ImportResolverNotProvidedError) Unwrap

type Result

type Result struct {
	TestName string
	Error    error
}

type Results

type Results []Result

type TestRunner

type TestRunner struct {
	// contains filtered or unexported fields
}

TestRunner runs tests.

func NewTestRunner

func NewTestRunner() *TestRunner

func (*TestRunner) RunTest

func (r *TestRunner) RunTest(script string, funcName string) (result *Result, err error)

RunTest runs a single test in the provided test script.

func (*TestRunner) RunTests

func (r *TestRunner) RunTests(script string) (results Results, err error)

RunTests runs all the tests in the provided test script.

func (*TestRunner) WithFileResolver

func (r *TestRunner) WithFileResolver(fileResolver FileResolver) *TestRunner

func (*TestRunner) WithImportResolver

func (r *TestRunner) WithImportResolver(importResolver ImportResolver) *TestRunner

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL