scenexec

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: GPL-3.0 Imports: 22 Imported by: 9

Documentation

Index

Constants

View Source
const RewardKey = core.ProtectedKeyPrefix + "reward"

RewardKey is the storage key where the protocol writes when sending out rewards.

Variables

View Source
var DefaultCodeMetadata = []byte{0x05, 0x06}

DefaultCodeMetadata indicates what code metadata to use in smart contracts if unspecified

View Source
var TestVMType = []byte{0, 0}

TestVMType is the VM type argument we use in tests.

Functions

func DisableLoggingForTests

func DisableLoggingForTests()

DisableLoggingForTests sets log level to *:NONE

func SetLoggingForTests

func SetLoggingForTests()

SetLoggingForTests configures the logger package with *:TRACE and enabled logger names

func SetLoggingForTestsWithLogger

func SetLoggingForTestsWithLogger(loggerName string)

SetLoggingForTestsWithLogger configures the logger package with a certain logger

Types

type ScenarioExecutor

type ScenarioExecutor struct {
	World *worldmock.MockWorld
	// contains filtered or unexported fields
}

ScenarioExecutor parses, interprets and executes both .test.json tests and .scen.json scenarios with VM.

func NewScenarioExecutor

func NewScenarioExecutor(vmBuilder VMBuilder) *ScenarioExecutor

NewScenarioExecutor prepares a new VMTestExecutor instance.

func (*ScenarioExecutor) Close

func (ae *ScenarioExecutor) Close()

Close will simply close the VM

func (*ScenarioExecutor) DumpWorld

func (ae *ScenarioExecutor) DumpWorld() error

DumpWorld prints the state of the MockWorld to stdout.

func (*ScenarioExecutor) ExecuteCheckStateStep

func (ae *ScenarioExecutor) ExecuteCheckStateStep(step *scenmodel.CheckStateStep) error

ExecuteCheckStateStep executes a CheckStateStep defined by the current scenario.

func (*ScenarioExecutor) ExecuteExternalStep

func (ae *ScenarioExecutor) ExecuteExternalStep(step *scenmodel.ExternalStepsStep) error

ExecuteExternalStep executes an external step referenced by the scenario.

func (*ScenarioExecutor) ExecuteSetStateStep

func (ae *ScenarioExecutor) ExecuteSetStateStep(step *scenmodel.SetStateStep) error

ExecuteSetStateStep executes a SetStateStep.

func (*ScenarioExecutor) ExecuteStep

func (ae *ScenarioExecutor) ExecuteStep(generalStep scenmodel.Step) error

ExecuteStep executes an individual step from a scenario.

func (*ScenarioExecutor) ExecuteTxStep

func (ae *ScenarioExecutor) ExecuteTxStep(step *scenmodel.TxStep) (*vmcommon.VMOutput, error)

ExecuteTxStep executes a TxStep.

func (*ScenarioExecutor) GetVM

GetVM yields a reference to the VMExecutionHandler used.

func (*ScenarioExecutor) GetVMType

func (ae *ScenarioExecutor) GetVMType() []byte

GetVM returns the configured VM type.

func (*ScenarioExecutor) InitVM

func (ae *ScenarioExecutor) InitVM(scenGasSchedule scenmodel.GasSchedule) error

InitVM will initialize the VM and the builtin function container. Does nothing if the VM is already initialized.

func (*ScenarioExecutor) PeekTraceGas

func (ae *ScenarioExecutor) PeekTraceGas() bool

PeekTraceGas returns the last position from the scenarioTraceGas, if existing

func (*ScenarioExecutor) PutNewAccount

func (ae *ScenarioExecutor) PutNewAccount(scenAccount *scenmodel.Account) error

PutNewAccount Puts a new account in world account map. Overwrites.

func (*ScenarioExecutor) Reset

func (ae *ScenarioExecutor) Reset()

Reset clears state/world. Is called in RunAllJSONScenariosInDirectory, but not in RunSingleJSONScenario.

func (*ScenarioExecutor) RunScenario

func (ae *ScenarioExecutor) RunScenario(scenario *scenmodel.Scenario, fileResolver fr.FileResolver) error

RunScenario executes an individual test.

func (*ScenarioExecutor) UpdateAccount

func (ae *ScenarioExecutor) UpdateAccount(scenAccount *scenmodel.Account) error

UpdateAccount Updates an account in world account map.

type VMBuilder

type VMBuilder interface {
	// NewMockWorld defines how the MockWorld is initialized.
	NewMockWorld() *worldmock.MockWorld

	// GasScheduleMapFromScenarios converts the gas schedule name from a scenario into an actual gas map.
	GasScheduleMapFromScenarios(scenGasSchedule scenmodel.GasSchedule) (worldmock.GasScheduleMap, error)

	// GetVMType returns the configured VM type, normally [5, 0].
	GetVMType() []byte

	// NewVM creates the execution VM host with references to the world mock and gas schedule.
	NewVM(world *worldmock.MockWorld, gasSchedule map[string]map[string]uint64) (VMInterface, error)
}

VMBuilder defines VM initialization.

The VM is not passed directly to the scenario executor because the scenario can override the gas schedule, which is required during initialization.

type VMInterface

type VMInterface interface {
	vmcommon.VMExecutionHandler

	Reset()
	SetGasTracing(enableGasTracing bool)
	GetGasTrace() map[string]map[string][]uint64
}

VMInterface is the VM interface as defined in vm-common, plus a few extra methods needed for running the scenarios

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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