testutils

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0, LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunEqualTests added in v0.5.1

func RunEqualTests(t *testing.T, tests map[string]ConfigEqualTest)

func RunPrecompileTests added in v0.5.3

func RunPrecompileTests(t *testing.T, module modules.Module, newStateDB func(t testing.TB) contract.StateDB, contractTests map[string]PrecompileTest)

func RunPredicateBenchmarks added in v0.5.3

func RunPredicateBenchmarks(b *testing.B, predicateTests map[string]PredicateTest)

func RunPredicateTests added in v0.5.3

func RunPredicateTests(t *testing.T, predicateTests map[string]PredicateTest)

func RunVerifyTests added in v0.5.1

func RunVerifyTests(t *testing.T, tests map[string]ConfigVerifyTest)

Types

type ConfigEqualTest added in v0.5.0

type ConfigEqualTest struct {
	Config   precompileconfig.Config
	Other    precompileconfig.Config
	Expected bool
}

ConfigEqualTest is a test case for comparing two configs

type ConfigVerifyTest added in v0.5.0

type ConfigVerifyTest struct {
	Config        precompileconfig.Config
	ChainConfig   precompileconfig.ChainConfig
	ExpectedError string
}

ConfigVerifyTest is a test case for verifying a config

type PrecompileRunparams added in v0.5.0

type PrecompileRunparams struct {
	AccessibleState contract.AccessibleState
	Caller          common.Address
	ContractAddress common.Address
	Input           []byte
	SuppliedGas     uint64
	ReadOnly        bool
}

type PrecompileTest

type PrecompileTest struct {
	// Caller is the address of the precompile caller
	Caller common.Address
	// Input the raw input bytes to the precompile
	Input []byte
	// InputFn is a function that returns the raw input bytes to the precompile
	// If specified, Input will be ignored.
	InputFn func(t testing.TB) []byte
	// SuppliedGas is the amount of gas supplied to the precompile
	SuppliedGas uint64
	// ReadOnly is whether the precompile should be called in read only
	// mode. If true, the precompile should not modify the state.
	ReadOnly bool
	// Config is the config to use for the precompile
	// It should be the same precompile config that is used in the
	// precompile's configurator.
	// If nil, Configure will not be called.
	Config precompileconfig.Config
	// BeforeHook is called before the precompile is called.
	BeforeHook func(t testing.TB, state contract.StateDB)
	// SetupBlockContext sets the expected calls on MockBlockContext for the test execution.
	SetupBlockContext func(*contract.MockBlockContext)
	// AfterHook is called after the precompile is called.
	AfterHook func(t testing.TB, state contract.StateDB)
	// ExpectedRes is the expected raw byte result returned by the precompile
	ExpectedRes []byte
	// ExpectedErr is the expected error returned by the precompile
	ExpectedErr string
	// ChainConfigFn returns the chain config to use for the precompile's block context
	// If nil, the default chain config will be used.
	ChainConfigFn func(*gomock.Controller) precompileconfig.ChainConfig
}

PrecompileTest is a test case for a precompile

func (PrecompileTest) Bench added in v0.5.0

func (test PrecompileTest) Bench(b *testing.B, module modules.Module, state contract.StateDB)

func (PrecompileTest) Run

func (test PrecompileTest) Run(t *testing.T, module modules.Module, state contract.StateDB)

type PredicateTest added in v0.5.3

type PredicateTest struct {
	Config precompileconfig.Config

	PredicateContext *precompileconfig.PredicateContext

	PredicateBytes []byte
	Gas            uint64
	GasErr         error
	ExpectedErr    error
}

PredicateTest defines a unit test/benchmark for verifying a precompile predicate.

func (PredicateTest) Run added in v0.5.3

func (test PredicateTest) Run(t testing.TB)

func (PredicateTest) RunBenchmark added in v0.5.3

func (test PredicateTest) RunBenchmark(b *testing.B)

Jump to

Keyboard shortcuts

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