test

package module
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BurnFlow []byte
View Source
var GetCurrentBlockHeight []byte
View Source
var GetFlowBalance []byte
View Source
var MintFlowTransaction []byte
View Source
var StorageIDUndefined = atree.StorageID{}

Functions

func NewTestFrameworkProvider added in v0.13.0

func NewTestFrameworkProvider(
	logger zerolog.Logger,
	fileResolver FileResolver,
	stdlibHandler stdlib.StandardLibraryHandler,
	coverageReport *runtime.CoverageReport,
) stdlib.TestFramework

func PrettyPrintResult

func PrettyPrintResult(funcName string, err error) string

func PrettyPrintResults

func PrettyPrintResults(results Results, scriptPath string) 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(
	logger zerolog.Logger,
	fileResolver FileResolver,
	stdlibHandler stdlib.StandardLibraryHandler,
	coverageReport *runtime.CoverageReport,
) *EmulatorBackend

func (*EmulatorBackend) AddTransaction

func (e *EmulatorBackend) AddTransaction(
	inter *interpreter.Interpreter,
	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) CreateSnapshot added in v0.13.0

func (e *EmulatorBackend) CreateSnapshot(name string) error

Creates a snapshot of the blockchain, at the current ledger state, with the given name.

func (*EmulatorBackend) DeployContract

func (e *EmulatorBackend) DeployContract(
	inter *interpreter.Interpreter,
	name string,
	path string,
	args []interpreter.Value,
) error

func (*EmulatorBackend) Events added in v0.8.0

Events returns all the emitted events up until the latest block, optionally filtered by event type.

func (*EmulatorBackend) ExecuteNextTransaction

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

func (*EmulatorBackend) GetAccount added in v0.13.0

func (e *EmulatorBackend) GetAccount(
	address interpreter.AddressValue,
) (*stdlib.Account, error)

func (*EmulatorBackend) LoadSnapshot added in v0.13.0

func (e *EmulatorBackend) LoadSnapshot(name string) error

Loads a snapshot of the blockchain, with the given name, and updates the current ledger state.

func (*EmulatorBackend) Logs added in v0.8.0

func (e *EmulatorBackend) Logs() []string

Logs returns all the log messages from the blockchain.

func (*EmulatorBackend) MoveTime added in v0.13.0

func (e *EmulatorBackend) MoveTime(timeDelta int64)

Moves the time of the Blockchain's clock, by the given time delta, in the form of seconds.

func (*EmulatorBackend) Reset added in v0.8.0

func (e *EmulatorBackend) Reset(height uint64)

func (*EmulatorBackend) RunScript

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

func (*EmulatorBackend) ServiceAccount added in v0.8.0

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

func (*EmulatorBackend) StandardLibraryHandler added in v0.3.0

func (e *EmulatorBackend) StandardLibraryHandler() stdlib.StandardLibraryHandler

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 TestFrameworkProvider added in v0.13.0

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

func (*TestFrameworkProvider) EmulatorBackend added in v0.13.0

func (tf *TestFrameworkProvider) EmulatorBackend() stdlib.Blockchain

func (*TestFrameworkProvider) ReadFile added in v0.13.0

func (tf *TestFrameworkProvider) ReadFile(path string) (string, error)

type TestRunner

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

TestRunner runs tests.

func NewTestRunner

func NewTestRunner() *TestRunner

func (*TestRunner) GetTests added in v0.14.4

func (r *TestRunner) GetTests(script string) ([]string, error)

func (*TestRunner) Logs added in v0.8.1

func (r *TestRunner) Logs() []string

Logs returns all the log messages from the script environment that test cases run. Unit tests run in this environment too, so the logs from their respective contracts, also appear in the resulting string slice.

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) WithContracts added in v0.13.0

func (r *TestRunner) WithContracts(contracts map[string]common.Address) *TestRunner

func (*TestRunner) WithCoverageReport added in v0.6.0

func (r *TestRunner) WithCoverageReport(coverageReport *runtime.CoverageReport) *TestRunner

func (*TestRunner) WithFileResolver

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

func (*TestRunner) WithImportResolver

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

func (*TestRunner) WithLogger added in v0.14.6

func (r *TestRunner) WithLogger(logger zerolog.Logger) *TestRunner

func (*TestRunner) WithRandomSeed added in v0.13.0

func (r *TestRunner) WithRandomSeed(seed int64) *TestRunner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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