vm

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: GPL-3.0 Imports: 71 Imported by: 0

Documentation

Index

Constants

View Source
const DNSV2Address = "erd1qqqqqqqqqqqqqpgqcy67yanvwpepqmerkq6m8pgav0tlvgwxjmdq4hukxw"

DNSV2Address defines the address for the new DNS contract

View Source
const DNSV2DeployerAddress = "erd1uzk2g5rhvg8prk9y50d0q7qsxg7tm7f320q0q4qlpmfu395wjmdqqy0n9q"

DNSV2DeployerAddress defines the address of the deployer for the DNS v2 contracts

View Source
const EpochGuardianDelay = uint32(2)

EpochGuardianDelay is the test constant for the delay in epochs for the guardian feature

Variables

View Source
var TestAddressPubkeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(32, "erd")

TestAddressPubkeyConverter represents an address public key converter

Functions

func AccountExists

func AccountExists(accnts state.AccountsAdapter, addressBytes []byte) bool

AccountExists -

func ComputeExpectedBalance

func ComputeExpectedBalance(
	existing *big.Int,
	transferred *big.Int,
	gasLimit uint64,
	gasPrice uint64,
) *big.Int

ComputeExpectedBalance -

func ComputeGasLimit

func ComputeGasLimit(gasSchedule map[string]map[string]uint64, testContext *VMTestContext, tx *dataTx.Transaction) uint64

ComputeGasLimit -

func CreateAccount

func CreateAccount(accnts state.AccountsAdapter, pubKey []byte, nonce uint64, balance *big.Int) ([]byte, error)

CreateAccount -

func CreateDeployTx

func CreateDeployTx(
	senderAddressBytes []byte,
	senderNonce uint64,
	value *big.Int,
	gasPrice uint64,
	gasLimit uint64,
	scCodeAndVMType string,
) *dataTransaction.Transaction

CreateDeployTx -

func CreateEmptyAddress

func CreateEmptyAddress() []byte

CreateEmptyAddress -

func CreateMockGasScheduleNotifier added in v1.4.9

func CreateMockGasScheduleNotifier() *mock.GasScheduleNotifierMock

CreateMockGasScheduleNotifier will create a mock gas schedule notifier to be used in tests

func CreateOneSCExecutorMockVM

func CreateOneSCExecutorMockVM(accnts state.AccountsAdapter) vmcommon.VMExecutionHandler

CreateOneSCExecutorMockVM -

func CreatePreparedTxProcessorAndAccountsWithMockedVM

func CreatePreparedTxProcessorAndAccountsWithMockedVM(
	vmOpGas uint64,
	senderNonce uint64,
	senderAddressBytes []byte,
	senderBalance *big.Int,
	enableEpochs config.EnableEpochs,
	wasmVMChangeLocker common.Locker,
) (process.TransactionProcessor, state.AccountsAdapter, error)

CreatePreparedTxProcessorAndAccountsWithMockedVM -

func CreatePreparedTxProcessorAndAccountsWithMockedVMWithRoundsConfig added in v1.6.0

func CreatePreparedTxProcessorAndAccountsWithMockedVMWithRoundsConfig(
	vmOpGas uint64,
	senderNonce uint64,
	senderAddressBytes []byte,
	senderBalance *big.Int,
	enableEpochs config.EnableEpochs,
	roundsConfig config.RoundConfig,
	wasmVMChangeLocker common.Locker,
) (process.TransactionProcessor, state.AccountsAdapter, error)

CreatePreparedTxProcessorAndAccountsWithMockedVMWithRoundsConfig -

func CreateTransaction

func CreateTransaction(
	nonce uint64,
	value *big.Int,
	sndAddress []byte,
	rcvAddress []byte,
	gasprice uint64,
	gasLimit uint64,
	data []byte,
) *dataTransaction.Transaction

CreateTransaction -

func CreateTransferTokenTx

func CreateTransferTokenTx(
	nonce uint64,
	functionName string,
	value *big.Int,
	scAddrress []byte,
	sndAddress []byte,
	rcvAddress []byte,
) *dataTransaction.Transaction

CreateTransferTokenTx -

func CreateTx

func CreateTx(
	senderAddressBytes []byte,
	receiverAddressBytes []byte,
	senderNonce uint64,
	value *big.Int,
	gasPrice uint64,
	gasLimit uint64,
	scCodeOrFunc string,
) *dataTransaction.Transaction

CreateTx -

func CreateTxProcessorWithOneSCExecutorMockVM

func CreateTxProcessorWithOneSCExecutorMockVM(
	accnts state.AccountsAdapter,
	opGas uint64,
	enableEpochsConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
	wasmVMChangeLocker common.Locker,
) (process.TransactionProcessor, error)

CreateTxProcessorWithOneSCExecutorMockVM -

func CreateVMAndBlockchainHookAndDataPool

func CreateVMAndBlockchainHookAndDataPool(
	accnts state.AccountsAdapter,
	gasSchedule core.GasScheduleNotifier,
	vmConfig *config.VirtualMachineConfig,
	shardCoordinator sharding.Coordinator,
	wasmVMChangeLocker common.Locker,
	epochNotifierInstance process.EpochNotifier,
	enableEpochsHandler common.EnableEpochsHandler,
	chainHandler data.ChainHandler,
	guardedAccountHandler vmcommon.GuardedAccountHandler,
) (process.VirtualMachinesContainer, *hooks.BlockChainHookImpl, dataRetriever.PoolsHolder)

CreateVMAndBlockchainHookAndDataPool -

func CreateVMAndBlockchainHookMeta

func CreateVMAndBlockchainHookMeta(
	validatorAccounts state.AccountsAdapter,
	gasSchedule core.GasScheduleNotifier,
	shardCoordinator sharding.Coordinator,
	userAccounts state.AccountsAdapter,
	enableEpochsConfig config.EnableEpochs,
) (process.VirtualMachinesContainer, *hooks.BlockChainHookImpl)

CreateVMAndBlockchainHookMeta -

func CreateVMConfigWithVersion added in v1.6.0

func CreateVMConfigWithVersion(version string) *config.VirtualMachineConfig

CreateVMConfigWithVersion -

func GetIntValueFromSC

func GetIntValueFromSC(
	gasSchedule map[string]map[string]uint64,
	accnts state.AccountsAdapter,
	scAddressBytes []byte,
	funcName string,
	args ...[]byte,
) *big.Int

GetIntValueFromSC -

func GetNodeIndex

GetNodeIndex -

func GetStringValueFromSC added in v1.6.0

func GetStringValueFromSC(
	gasSchedule map[string]map[string]uint64,
	accnts state.AccountsAdapter,
	scAddressBytes []byte,
	funcName string,
	args ...[]byte,
) string

GetStringValueFromSC -

func GetVmOutput

func GetVmOutput(
	gasSchedule map[string]map[string]uint64,
	accnts state.AccountsAdapter,
	scAddressBytes []byte,
	funcName string,
	args ...[]byte) *vmcommon.VMOutput

GetVmOutput -

func TestAccount

func TestAccount(
	t *testing.T,
	accnts state.AccountsAdapter,
	senderAddressBytes []byte,
	expectedNonce uint64,
	expectedBalance *big.Int,
) *big.Int

TestAccount -

func TestAccountUsername added in v1.6.0

func TestAccountUsername(
	t *testing.T,
	accnts state.AccountsAdapter,
	senderAddressBytes []byte,
	username []byte,
)

TestAccountUsername -

func TestDeployedContractContents

func TestDeployedContractContents(
	t *testing.T,
	destinationAddressBytes []byte,
	accnts state.AccountsAdapter,
	requiredBalance *big.Int,
	scCode string,
	dataValues map[string]*big.Int,
)

TestDeployedContractContents -

Types

type ResultsCreateTxProcessor

type ResultsCreateTxProcessor struct {
	TxProc             process.TransactionProcessor
	SCProc             scrCommon.TestSmartContractProcessor
	IntermediateTxProc process.IntermediateTransactionHandler
	EconomicsHandler   process.EconomicsDataHandler
	CostHandler        external.TransactionEvaluator
	TxLogProc          process.TransactionLogProcessor
}

ResultsCreateTxProcessor is the struct that will hold all needed processor instances

func CreateTxProcessorWithOneSCExecutorWithVMs

func CreateTxProcessorWithOneSCExecutorWithVMs(
	accnts state.AccountsAdapter,
	vmContainer process.VirtualMachinesContainer,
	blockChainHook *hooks.BlockChainHookImpl,
	feeAccumulator process.TransactionFeeHandler,
	shardCoordinator sharding.Coordinator,
	enableEpochsConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
	wasmVMChangeLocker common.Locker,
	poolsHolder dataRetriever.PoolsHolder,
	epochNotifierInstance process.EpochNotifier,
	guardianChecker process.GuardianChecker,
	roundNotifierInstance process.RoundNotifier,
	chainHandler data.ChainHandler,
) (*ResultsCreateTxProcessor, error)

CreateTxProcessorWithOneSCExecutorWithVMs -

type VMTestAccount

type VMTestAccount struct {
	Balance      *big.Int
	Address      []byte
	Nonce        uint64
	TokenBalance *big.Int
}

VMTestAccount -

type VMTestContext

type VMTestContext struct {
	ChainHandler           *testscommon.ChainHandlerStub
	TxProcessor            process.TransactionProcessor
	ScProcessor            scrCommon.TestSmartContractProcessor
	Accounts               state.AccountsAdapter
	BlockchainHook         vmcommon.BlockchainHook
	VMContainer            process.VirtualMachinesContainer
	TxFeeHandler           process.TransactionFeeHandler
	ShardCoordinator       sharding.Coordinator
	ScForwarder            process.IntermediateTransactionHandler
	EconomicsData          process.EconomicsDataHandler
	Marshalizer            marshal.Marshalizer
	GasSchedule            core.GasScheduleNotifier
	VMConfiguration        *config.VirtualMachineConfig
	EpochNotifier          process.EpochNotifier
	EnableEpochsHandler    common.EnableEpochsHandler
	SCQueryService         *smartContract.SCQueryService
	GuardedAccountsHandler process.GuardedAccountHandler

	Alice         VMTestAccount
	Bob           VMTestAccount
	ContractOwner VMTestAccount
	Contract      VMTestAccount

	TxCostHandler    external.TransactionEvaluator
	TxsLogsProcessor process.TransactionLogProcessor
}

VMTestContext -

func CreatePreparedTxProcessorAndAccountsWithVMs

func CreatePreparedTxProcessorAndAccountsWithVMs(
	senderNonce uint64,
	senderAddressBytes []byte,
	senderBalance *big.Int,
	enableEpochsConfig config.EnableEpochs,
) (*VMTestContext, error)

CreatePreparedTxProcessorAndAccountsWithVMs -

func CreatePreparedTxProcessorAndAccountsWithVMsWithRoundsConfig added in v1.6.0

func CreatePreparedTxProcessorAndAccountsWithVMsWithRoundsConfig(
	senderNonce uint64,
	senderAddressBytes []byte,
	senderBalance *big.Int,
	enableEpochsConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
) (*VMTestContext, error)

CreatePreparedTxProcessorAndAccountsWithVMsWithRoundsConfig -

func CreatePreparedTxProcessorWithVMConfigWithShardCoordinatorDBAndGasAndRoundConfig added in v1.6.0

func CreatePreparedTxProcessorWithVMConfigWithShardCoordinatorDBAndGasAndRoundConfig(
	enableEpochsConfig config.EnableEpochs,
	shardCoordinator sharding.Coordinator,
	db storage.Storer,
	gasScheduleNotifier core.GasScheduleNotifier,
	roundsConfig config.RoundConfig,
	vmConfig *config.VirtualMachineConfig,
) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMConfigWithShardCoordinatorDBAndGasAndRoundConfig -

func CreatePreparedTxProcessorWithVMs

func CreatePreparedTxProcessorWithVMs(enableEpochs config.EnableEpochs) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMs -

func CreatePreparedTxProcessorWithVMsAndCustomGasSchedule

func CreatePreparedTxProcessorWithVMsAndCustomGasSchedule(
	enableEpochs config.EnableEpochs,
	updateGasSchedule func(gasMap wasmConfig.GasScheduleMap)) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsAndCustomGasSchedule -

func CreatePreparedTxProcessorWithVMsMultiShard

func CreatePreparedTxProcessorWithVMsMultiShard(selfShardID uint32, enableEpochsConfig config.EnableEpochs) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsMultiShard -

func CreatePreparedTxProcessorWithVMsMultiShardAndRoundConfig added in v1.6.0

func CreatePreparedTxProcessorWithVMsMultiShardAndRoundConfig(selfShardID uint32, enableEpochsConfig config.EnableEpochs, roundsConfig config.RoundConfig) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsMultiShardAndRoundConfig -

func CreatePreparedTxProcessorWithVMsMultiShardRoundVMConfig added in v1.6.0

func CreatePreparedTxProcessorWithVMsMultiShardRoundVMConfig(
	selfShardID uint32,
	enableEpochsConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
	vmConfig *config.VirtualMachineConfig,
) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsMultiShardRoundVMConfig -

func CreatePreparedTxProcessorWithVMsWithShardCoordinator

func CreatePreparedTxProcessorWithVMsWithShardCoordinator(enableEpochsConfig config.EnableEpochs, shardCoordinator sharding.Coordinator) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsWithShardCoordinator -

func CreatePreparedTxProcessorWithVMsWithShardCoordinatorAndRoundConfig added in v1.6.0

func CreatePreparedTxProcessorWithVMsWithShardCoordinatorAndRoundConfig(enableEpochsConfig config.EnableEpochs, roundsConfig config.RoundConfig, shardCoordinator sharding.Coordinator) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsWithShardCoordinatorAndRoundConfig -

func CreatePreparedTxProcessorWithVMsWithShardCoordinatorDBAndGas

func CreatePreparedTxProcessorWithVMsWithShardCoordinatorDBAndGas(
	enableEpochsConfig config.EnableEpochs,
	shardCoordinator sharding.Coordinator,
	db storage.Storer,
	gasScheduleNotifier core.GasScheduleNotifier,
) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsWithShardCoordinatorDBAndGas -

func CreatePreparedTxProcessorWithVMsWithShardCoordinatorDBAndGasAndRoundConfig added in v1.6.0

func CreatePreparedTxProcessorWithVMsWithShardCoordinatorDBAndGasAndRoundConfig(
	enableEpochsConfig config.EnableEpochs,
	shardCoordinator sharding.Coordinator,
	db storage.Storer,
	gasScheduleNotifier core.GasScheduleNotifier,
	roundsConfig config.RoundConfig,
) (*VMTestContext, error)

CreatePreparedTxProcessorWithVMsWithShardCoordinatorDBAndGasAndRoundConfig -

func CreateTxProcessorArwenVMWithGasScheduleAndRoundConfig added in v1.6.0

func CreateTxProcessorArwenVMWithGasScheduleAndRoundConfig(
	senderNonce uint64,
	senderAddressBytes []byte,
	senderBalance *big.Int,
	gasScheduleMap map[string]map[string]uint64,
	enableEpochsConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
) (*VMTestContext, error)

CreateTxProcessorArwenVMWithGasScheduleAndRoundConfig -

func CreateTxProcessorArwenWithVMConfigAndRoundConfig added in v1.6.0

func CreateTxProcessorArwenWithVMConfigAndRoundConfig(
	enableEpochsConfig config.EnableEpochs,
	roundsConfig config.RoundConfig,
	vmConfig *config.VirtualMachineConfig,
	gasSchedule map[string]map[string]uint64,
) (*VMTestContext, error)

CreateTxProcessorArwenWithVMConfigAndRoundConfig -

func CreateTxProcessorWasmVMWithGasSchedule

func CreateTxProcessorWasmVMWithGasSchedule(
	senderNonce uint64,
	senderAddressBytes []byte,
	senderBalance *big.Int,
	gasScheduleMap map[string]map[string]uint64,
	enableEpochsConfig config.EnableEpochs,
) (*VMTestContext, error)

CreateTxProcessorWasmVMWithGasSchedule -

func CreateTxProcessorWasmVMWithVMConfig

func CreateTxProcessorWasmVMWithVMConfig(
	enableEpochsConfig config.EnableEpochs,
	vmConfig *config.VirtualMachineConfig,
	gasSchedule map[string]map[string]uint64,
) (*VMTestContext, error)

CreateTxProcessorWasmVMWithVMConfig -

func (*VMTestContext) CleanIntermediateTransactions

func (vmTestContext *VMTestContext) CleanIntermediateTransactions(tb testing.TB)

CleanIntermediateTransactions -

func (*VMTestContext) Close

func (vmTestContext *VMTestContext) Close()

Close -

func (*VMTestContext) CreateAccount

func (vmTestContext *VMTestContext) CreateAccount(account *VMTestAccount)

CreateAccount -

func (*VMTestContext) CreateBlockStarted

func (vmTestContext *VMTestContext) CreateBlockStarted()

CreateBlockStarted -

func (*VMTestContext) CreateTransaction

func (vmTestContext *VMTestContext) CreateTransaction(
	sender *VMTestAccount,
	receiver *VMTestAccount,
	value *big.Int,
	gasprice uint64,
	gasLimit uint64,
	data []byte,
) *dataTransaction.Transaction

CreateTransaction -

func (*VMTestContext) CreateTransferTokenTx

func (vmTestContext *VMTestContext) CreateTransferTokenTx(
	sender *VMTestAccount,
	receiver *VMTestAccount,
	value *big.Int,
	functionName string,
) *dataTransaction.Transaction

CreateTransferTokenTx -

func (*VMTestContext) GetCompositeTestError

func (vmTestContext *VMTestContext) GetCompositeTestError() error

GetCompositeTestError -

func (*VMTestContext) GetGasRemaining

func (vmTestContext *VMTestContext) GetGasRemaining() uint64

GetGasRemaining -

func (*VMTestContext) GetIntValueFromSCWithTransientVM

func (vmTestContext *VMTestContext) GetIntValueFromSCWithTransientVM(funcName string, args ...[]byte) *big.Int

GetIntValueFromSCWithTransientVM -

func (*VMTestContext) GetIntermediateTransactions

func (vmTestContext *VMTestContext) GetIntermediateTransactions(tb testing.TB) []data.TransactionHandler

GetIntermediateTransactions -

func (*VMTestContext) GetVMOutputWithTransientVM

func (vmTestContext *VMTestContext) GetVMOutputWithTransientVM(funcName string, args ...[]byte) *vmcommon.VMOutput

GetVMOutputWithTransientVM -

Jump to

Keyboard shortcuts

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