Documentation ¶
Index ¶
- Constants
- Variables
- func DisableLoggingForTests()
- func SetLoggingForTests()
- func SetLoggingForTestsWithLogger(loggerName string)
- type ScenarioExecutor
- func (ae *ScenarioExecutor) Close()
- func (ae *ScenarioExecutor) DumpWorld() error
- func (ae *ScenarioExecutor) ExecuteCheckStateStep(step *scenmodel.CheckStateStep) error
- func (ae *ScenarioExecutor) ExecuteExternalStep(step *scenmodel.ExternalStepsStep) error
- func (ae *ScenarioExecutor) ExecuteSetStateStep(step *scenmodel.SetStateStep) error
- func (ae *ScenarioExecutor) ExecuteStep(generalStep scenmodel.Step) error
- func (ae *ScenarioExecutor) ExecuteTxStep(step *scenmodel.TxStep) (*vmcommon.VMOutput, error)
- func (ae *ScenarioExecutor) GetVM() vmcommon.VMExecutionHandler
- func (ae *ScenarioExecutor) GetVMType() []byte
- func (ae *ScenarioExecutor) InitVM(scenGasSchedule scenmodel.GasSchedule) error
- func (ae *ScenarioExecutor) PeekTraceGas() bool
- func (ae *ScenarioExecutor) PutNewAccount(scenAccount *scenmodel.Account) error
- func (ae *ScenarioExecutor) Reset()
- func (ae *ScenarioExecutor) RunScenario(scenario *scenmodel.Scenario, fileResolver fr.FileResolver) error
- func (ae *ScenarioExecutor) UpdateAccount(scenAccount *scenmodel.Account) error
- type VMBuilder
- type VMInterface
Constants ¶
const RewardKey = core.ProtectedKeyPrefix + "reward"
RewardKey is the storage key where the protocol writes when sending out rewards.
Variables ¶
var DefaultCodeMetadata = []byte{0x05, 0x06}
DefaultCodeMetadata indicates what code metadata to use in smart contracts if unspecified
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) 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 ¶
ExecuteTxStep executes a TxStep.
func (*ScenarioExecutor) GetVM ¶
func (ae *ScenarioExecutor) GetVM() vmcommon.VMExecutionHandler
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