Documentation ¶
Index ¶
- Variables
- func NewTestFrameworkProvider(logger zerolog.Logger, fileResolver FileResolver, ...) stdlib.TestFramework
- func PrettyPrintResult(funcName string, err error) string
- func PrettyPrintResults(results Results, scriptPath string) string
- type EmulatorBackend
- func (e *EmulatorBackend) AddTransaction(inter *interpreter.Interpreter, code string, authorizers []common.Address, ...) error
- func (e *EmulatorBackend) CommitBlock() error
- func (e *EmulatorBackend) CreateAccount() (*stdlib.Account, error)
- func (e *EmulatorBackend) CreateSnapshot(name string) error
- func (e *EmulatorBackend) DeployContract(inter *interpreter.Interpreter, name string, path string, ...) error
- func (e *EmulatorBackend) Events(inter *interpreter.Interpreter, eventType interpreter.StaticType) interpreter.Value
- func (e *EmulatorBackend) ExecuteNextTransaction() *stdlib.TransactionResult
- func (e *EmulatorBackend) GetAccount(address interpreter.AddressValue) (*stdlib.Account, error)
- func (e *EmulatorBackend) LoadSnapshot(name string) error
- func (e *EmulatorBackend) Logs() []string
- func (e *EmulatorBackend) MoveTime(timeDelta int64)
- func (e *EmulatorBackend) Reset(height uint64)
- func (e *EmulatorBackend) RunScript(inter *interpreter.Interpreter, code string, args []interpreter.Value) *stdlib.ScriptResult
- func (e *EmulatorBackend) ServiceAccount() (*stdlib.Account, error)
- func (e *EmulatorBackend) StandardLibraryHandler() stdlib.StandardLibraryHandler
- type FileResolver
- type FileResolverNotProvidedError
- type ImportResolver
- type ImportResolverNotProvidedError
- type Result
- type Results
- type TestFrameworkProvider
- type TestRunner
- func (r *TestRunner) GetTests(script string) ([]string, error)
- func (r *TestRunner) Logs() []string
- func (r *TestRunner) RunTest(script string, funcName string) (result *Result, err error)
- func (r *TestRunner) RunTests(script string) (results Results, err error)
- func (r *TestRunner) WithContracts(contracts map[string]common.Address) *TestRunner
- func (r *TestRunner) WithCoverageReport(coverageReport *runtime.CoverageReport) *TestRunner
- func (r *TestRunner) WithFileResolver(fileResolver FileResolver) *TestRunner
- func (r *TestRunner) WithImportResolver(importResolver ImportResolver) *TestRunner
- func (r *TestRunner) WithLogger(logger zerolog.Logger) *TestRunner
- func (r *TestRunner) WithRandomSeed(seed int64) *TestRunner
Constants ¶
This section is empty.
Variables ¶
var BurnFlow []byte
var GetCurrentBlockHeight []byte
var GetFlowBalance []byte
var MintFlowTransaction []byte
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 PrettyPrintResults ¶
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
func (e *EmulatorBackend) Events( inter *interpreter.Interpreter, eventType interpreter.StaticType, ) interpreter.Value
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 ¶
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 (e FileResolverNotProvidedError) Error() string
func (FileResolverNotProvidedError) Unwrap ¶
func (e FileResolverNotProvidedError) Unwrap() error
type ImportResolver ¶
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 (e ImportResolverNotProvidedError) Error() string
func (ImportResolverNotProvidedError) Unwrap ¶
func (e ImportResolverNotProvidedError) Unwrap() error
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
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