Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateMockAddress(creatorAddress []byte, creatorNonce uint64) []byte
- func IsSmartContractAddress(address []byte) bool
- type Account
- func (a *Account) AccountDataHandler() vmcommon.AccountDataHandler
- func (a *Account) AddToBalance(value *big.Int) error
- func (a *Account) AddToDeveloperReward(value *big.Int)
- func (a *Account) AddressBytes() []byte
- func (a *Account) ChangeOwnerAddress(sender []byte, newAddress []byte) error
- func (a *Account) ClaimDeveloperRewards(sender []byte) (*big.Int, error)
- func (a *Account) ClearDataCaches()
- func (a *Account) Clone() *Account
- func (a *Account) DirtyData() map[string][]byte
- func (a *Account) GetBalance() *big.Int
- func (a *Account) GetCode() []byte
- func (a *Account) GetCodeHash() []byte
- func (a *Account) GetCodeMetadata() []byte
- func (a *Account) GetDeveloperReward() *big.Int
- func (a *Account) GetNonce() uint64
- func (a *Account) GetOwnerAddress() []byte
- func (a *Account) GetRootHash() []byte
- func (a *Account) GetTokenBalance(tokenIdentifier []byte, nonce uint64) (*big.Int, error)
- func (a *Account) GetTokenBalanceUint64(tokenIdentifier []byte, nonce uint64) (uint64, error)
- func (a *Account) GetTokenData(tokenIdentifier []byte, nonce uint64, systemAccStorage map[string][]byte) (*esdt.ESDigitalToken, error)
- func (a *Account) GetUserName() []byte
- func (a *Account) IncreaseNonce(nonce uint64)
- func (a *Account) IsInterfaceNil() bool
- func (a *Account) RetrieveValue(key []byte) ([]byte, uint32, error)
- func (a *Account) SaveKeyValue(key []byte, value []byte) error
- func (a *Account) SetBalance(balance int64)
- func (a *Account) SetCode(code []byte)
- func (a *Account) SetCodeAndMetadata(code []byte, codeMetadata *vmcommon.CodeMetadata)
- func (a *Account) SetCodeHash(hash []byte)
- func (a *Account) SetCodeMetadata(codeMetadata []byte)
- func (a *Account) SetOwnerAddress(address []byte)
- func (a *Account) SetRootHash(hash []byte)
- func (a *Account) SetTokenBalance(tokenIdentifier []byte, nonce uint64, balance *big.Int) error
- func (a *Account) SetTokenBalanceUint64(tokenIdentifier []byte, nonce uint64, balance uint64) error
- func (a *Account) SetTokenData(tokenIdentifier []byte, nonce uint64, tokenData *esdt.ESDigitalToken) error
- func (a *Account) SetTokenRolesAsStrings(tokenIdentifier []byte, rolesAsStrings []string) error
- func (a *Account) SetUserName(userName []byte)
- func (a *Account) StorageValue(key string) []byte
- func (a *Account) SubFromBalance(value *big.Int) error
- func (a *Account) Validate() error
- type AccountMap
- func (am AccountMap) Clone() AccountMap
- func (am AccountMap) CreateAccount(address []byte, world *MockWorld) *Account
- func (am AccountMap) CreateSmartContractAccount(owner []byte, address []byte, code []byte, world *MockWorld) *Account
- func (am AccountMap) CreateSmartContractAccountWithCodeHash(owner []byte, address []byte, code []byte, codeHash []byte, world *MockWorld) *Account
- func (am AccountMap) DeleteAccount(address []byte)
- func (am AccountMap) GetAccount(address []byte) *Account
- func (am AccountMap) LoadAccountStorageFrom(otherAM AccountMap) error
- func (am AccountMap) PutAccount(account *Account)
- func (am AccountMap) PutAccounts(accounts []*Account)
- type BlockInfo
- type BuiltinFunctionsWrapper
- func (bf *BuiltinFunctionsWrapper) GetBuiltinFunctionNames() vmcommon.FunctionNames
- func (bf *BuiltinFunctionsWrapper) GetTokenBalance(address []byte, tokenIdentifier []byte, nonce uint64) (*big.Int, error)
- func (bf *BuiltinFunctionsWrapper) GetTokenData(address []byte, tokenIdentifier []byte, nonce uint64) (*esdt.ESDigitalToken, error)
- func (bf *BuiltinFunctionsWrapper) PerformDirectESDTTransfer(sender []byte, receiver []byte, token []byte, nonce uint64, value *big.Int, ...) (uint64, error)
- func (bf *BuiltinFunctionsWrapper) PerformDirectMultiESDTTransfer(sender []byte, receiver []byte, esdtTransfers []*mj.ESDTTxData, ...) (uint64, error)
- func (bf *BuiltinFunctionsWrapper) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
- func (bf *BuiltinFunctionsWrapper) SetTokenData(address []byte, tokenIdentifier []byte, nonce uint64, ...) error
- type EnableEpochsHandlerStub
- func (stub *EnableEpochsHandlerStub) CheckExecuteReadOnlyEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) CreateNFTThroughExecByCallerEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) DisableExecByCallerEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) FixFailExecutionOnErrorEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) FixOOGReturnCodeEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) IsAheadOfTimeGasUsageFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsAlwaysSaveTokenMetaDataEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsBuiltInFunctionsFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsCheckCorrectTokenIDForTransferRoleFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsCheckExecuteOnReadOnlyFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsCheckFrozenCollectionFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsCheckFunctionArgumentFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsCheckTransferFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsCreateNFTThroughExecByCallerFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsDisableExecByCallerFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsESDTNFTImprovementV1FlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsESDTTransferRoleFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsFailExecutionOnEveryAPIErrorFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsFixAsyncCallbackCheckFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsFixOOGReturnCodeFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsFixOldTokenLiquidityEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsGlobalMintBurnFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsInterfaceNil() bool
- func (stub *EnableEpochsHandlerStub) IsManagedCryptoAPIsFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsMaxBlockchainHookCountersFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsMultiESDTTransferFixOnCallBackFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsRefactorContextFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsRemoveNonUpdatedStorageFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsRepairCallbackFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsRuntimeMemStoreLimitEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsSCDeployFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsSaveToSystemAccountFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsSendAlwaysFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsStorageAPICostOptimizationFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsTransferToMetaFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsValueLengthCheckFlagEnabled() bool
- func (stub *EnableEpochsHandlerStub) IsWipeSingleNFTLiquidityDecreaseEnabled() bool
- func (stub *EnableEpochsHandlerStub) ManagedCryptoAPIEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) MultiESDTTransferAsyncCallBackEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) RefactorContextEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) RemoveNonUpdatedStorageEnableEpoch() uint32
- func (stub *EnableEpochsHandlerStub) StorageAPICostOptimizationEnableEpoch() uint32
- type MockAccountsAdapter
- func (m *MockAccountsAdapter) Commit() ([]byte, error)
- func (m *MockAccountsAdapter) GetCode(codeHash []byte) []byte
- func (m *MockAccountsAdapter) GetExistingAccount(address []byte) (vmcommon.AccountHandler, error)
- func (m *MockAccountsAdapter) GetNumCheckpoints() uint32
- func (m *MockAccountsAdapter) IsInterfaceNil() bool
- func (m *MockAccountsAdapter) IsPruningEnabled() bool
- func (m *MockAccountsAdapter) JournalLen() int
- func (m *MockAccountsAdapter) LoadAccount(address []byte) (vmcommon.AccountHandler, error)
- func (m *MockAccountsAdapter) RecreateTrie(_ []byte) error
- func (m *MockAccountsAdapter) RemoveAccount(address []byte) error
- func (m *MockAccountsAdapter) RevertToSnapshot(snapshotIndex int) error
- func (m *MockAccountsAdapter) RootHash() ([]byte, error)
- func (m *MockAccountsAdapter) SaveAccount(account vmcommon.AccountHandler) error
- func (m *MockAccountsAdapter) SetStateCheckpoint(_ []byte, _ context.Context)
- func (m *MockAccountsAdapter) SnapshotState(_ []byte, _ context.Context)
- type MockWorld
- func (b *MockWorld) Clear()
- func (b *MockWorld) ClearCompiledCodes()
- func (b *MockWorld) CommitChanges() error
- func (b *MockWorld) CommunicationIdentifier(destShardID uint32) string
- func (b *MockWorld) ComputeId(address []byte) uint32
- func (b *MockWorld) CreateStateBackup()
- func (b *MockWorld) CurrentEpoch() uint32
- func (b *MockWorld) CurrentNonce() uint64
- func (b *MockWorld) CurrentRandomSeed() []byte
- func (b *MockWorld) CurrentRound() uint64
- func (b *MockWorld) CurrentTimeStamp() uint64
- func (b *MockWorld) ExecuteSmartContractCallOnOtherVM(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
- func (b *MockWorld) GetAllState(accountAddress []byte) (map[string][]byte, error)
- func (b *MockWorld) GetBlockhash(nonce uint64) ([]byte, error)
- func (b *MockWorld) GetBuiltinFunctionNames() vmcommon.FunctionNames
- func (b *MockWorld) GetCode(acc vmcommon.UserAccountHandler) []byte
- func (b *MockWorld) GetCompiledCode(codeHash []byte) (bool, []byte)
- func (b *MockWorld) GetESDTToken(address []byte, tokenIdentifier []byte, nonce uint64) (*esdt.ESDigitalToken, error)
- func (b *MockWorld) GetShardOfAddress(address []byte) uint32
- func (b *MockWorld) GetSnapshot() int
- func (b *MockWorld) GetStateRootHash() []byte
- func (b *MockWorld) GetStorageData(accountAddress []byte, key []byte) ([]byte, uint32, error)
- func (b *MockWorld) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
- func (b *MockWorld) InitBuiltinFunctions(gasMap config.GasScheduleMap) error
- func (b *MockWorld) IsInterfaceNil() bool
- func (b *MockWorld) IsLimitedTransfer(_ []byte) bool
- func (b *MockWorld) IsPaused(_ []byte) bool
- func (b *MockWorld) IsPayable(sndAddress []byte, rcvAddress []byte) (bool, error)
- func (b *MockWorld) IsSmartContract(address []byte) bool
- func (b *MockWorld) LastEpoch() uint32
- func (b *MockWorld) LastNonce() uint64
- func (b *MockWorld) LastRandomSeed() []byte
- func (b *MockWorld) LastRound() uint64
- func (b *MockWorld) LastTimeStamp() uint64
- func (b *MockWorld) NewAddress(creatorAddress []byte, creatorNonce uint64, _ []byte) ([]byte, error)
- func (b *MockWorld) NumberOfShards() uint32
- func (b *MockWorld) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
- func (b *MockWorld) RevertToSnapshot(snapshot int) error
- func (b *MockWorld) RollbackChanges() error
- func (b *MockWorld) SameShard(firstAddress []byte, secondAddress []byte) bool
- func (b *MockWorld) SaveCompiledCode(codeHash []byte, code []byte)
- func (b *MockWorld) SelfId() uint32
- func (b *MockWorld) SetCurrentBlockHash(blockHash []byte)
- func (b *MockWorld) SetProvidedBlockchainHook(bh vmcommon.BlockchainHook)
- func (b *MockWorld) UpdateAccountFromOutputAccount(modAcct *vmcommon.OutputAccount)
- func (b *MockWorld) UpdateAccounts(outputAccounts map[string]*vmcommon.OutputAccount, accountsToDelete [][]byte) error
- func (b *MockWorld) UpdateBalance(address []byte, newBalance *big.Int) error
- func (b *MockWorld) UpdateBalanceWithDelta(address []byte, balanceDelta *big.Int) error
- func (b *MockWorld) UpdateWorldStateBefore(fromAddr []byte, gasLimit uint64, gasPrice uint64) error
- type NewAddressMock
Constants ¶
const SCAddressNumLeadingZeros = 8
SCAddressNumLeadingZeros is the number of zero bytes every smart contract address begins with.
Variables ¶
var DefaultHasher = blake2b.NewBlake2b()
DefaultHasher is an exposed value to use in tests
var DefaultVMType = []byte{0xF, 0xF}
DefaultVMType is an exposed value to use in tests
var ErrBuiltinFuncWrapperNotInitialized = errors.New("builtin function not found or container not initialized")
ErrBuiltinFuncWrapperNotInitialized means that the builtin function wrapper was used before initialization.
var ErrInsufficientFunds = errors.New("insufficient funds")
ErrInsufficientFunds signals the funds are insufficient for the move balance operation but the transaction fee is covered by the current balance.
var ErrInvalidAccount = errors.New("account does not exist")
ErrInvalidAccount signals that a certain account does not exist
var ErrInvalidAddressLength = errors.New("invalid address length")
ErrInvalidAddressLength indicates an incorrect length given for an address.
var ErrNilWorldMock = errors.New("nil worldmock")
ErrNilWorldMock signals that the WorldMock is nil but shouldn't be.
var ErrOperationNotPermitted = errors.New("operation not permitted")
ErrOperationNotPermitted indicates an operation rejected due to insufficient permissions.
var ErrTrieHandlingNotImplemented = errors.New("trie handling not implemented")
ErrTrieHandlingNotImplemented indicates that no trie-related operations are currently implemented.
var WorldMarshalizer = &marshal.GogoProtoMarshalizer{}
WorldMarshalizer is the global marshalizer to be used by the components of the BuiltinFunctionsWrapper.
Functions ¶
func GenerateMockAddress ¶
GenerateMockAddress simulates creation of a new address by the protocol.
func IsSmartContractAddress ¶
IsSmartContractAddress verifies the address format. Smart contract addresses start with 8 bytes of 0.
Types ¶
type Account ¶
type Account struct {
Exists bool
Address []byte
Nonce uint64
Balance *big.Int
BalanceDelta *big.Int
Storage map[string][]byte
RootHash []byte
Code []byte
CodeHash []byte
CodeMetadata []byte
OwnerAddress []byte
AsyncCallData string
Username []byte
DeveloperReward *big.Int
ShardID uint32
IsSmartContract bool
MockWorld *MockWorld
}
Account holds the account info
func (*Account) AccountDataHandler ¶
func (a *Account) AccountDataHandler() vmcommon.AccountDataHandler
AccountDataHandler -
func (*Account) AddToDeveloperReward ¶
AddToDeveloperReward -
func (*Account) ChangeOwnerAddress ¶
ChangeOwnerAddress -
func (*Account) ClaimDeveloperRewards ¶
ClaimDeveloperRewards -
func (*Account) GetDeveloperReward ¶
GetDeveloperReward -
func (*Account) GetTokenBalance ¶
GetTokenBalance returns the ESDT balance of the account, specified by the token key.
func (*Account) GetTokenBalanceUint64 ¶
GetTokenBalanceUint64 returns the ESDT balance of the account, specified by the token key.
func (*Account) GetTokenData ¶
func (a *Account) GetTokenData(tokenIdentifier []byte, nonce uint64, systemAccStorage map[string][]byte) (*esdt.ESDigitalToken, error)
GetTokenData gets the ESDT information related to a token from the storage of the account.
func (*Account) RetrieveValue ¶
RetrieveValue -
func (*Account) SaveKeyValue ¶
SaveKeyValue -
func (*Account) SetCodeAndMetadata ¶
func (a *Account) SetCodeAndMetadata(code []byte, codeMetadata *vmcommon.CodeMetadata)
SetCodeAndMetadata changes the account code, as well as all fields depending on it: CodeHash, IsSmartContract, CodeMetadata. The code metadata must be given explicitly.
func (*Account) SetCodeMetadata ¶
SetCodeMetadata -
func (*Account) SetOwnerAddress ¶
SetOwnerAddress -
func (*Account) SetTokenBalance ¶
SetTokenBalance sets the ESDT balance of the account, specified by the token key.
func (*Account) SetTokenBalanceUint64 ¶
SetTokenBalanceUint64 sets the ESDT balance of the account, specified by the token key.
func (*Account) SetTokenData ¶
func (a *Account) SetTokenData(tokenIdentifier []byte, nonce uint64, tokenData *esdt.ESDigitalToken) error
SetTokenData sets the ESDT information related to a token into the storage of the account.
func (*Account) SetTokenRolesAsStrings ¶
SetTokenRolesAsStrings sets the specified roles to the account, corresponding to the given tokenName.
func (*Account) StorageValue ¶
StorageValue yields the storage value for key, default 0
func (*Account) SubFromBalance ¶
SubFromBalance -
type AccountMap ¶
AccountMap is a map from address to Account, also implementing the AccountsAdapter interface
func NewAccountMap ¶
func NewAccountMap() AccountMap
NewAccountMap creates a new AccountMap instance.
func (AccountMap) Clone ¶
func (am AccountMap) Clone() AccountMap
Clone creates a deep clone of the entire AccountMap.
func (AccountMap) CreateAccount ¶
func (am AccountMap) CreateAccount(address []byte, world *MockWorld) *Account
CreateAccount instantiates an empty account for the given address.
func (AccountMap) CreateSmartContractAccount ¶
func (am AccountMap) CreateSmartContractAccount(owner []byte, address []byte, code []byte, world *MockWorld) *Account
CreateSmartContractAccount instantiates an account for a smart contract with the given address and WASM bytecode.
func (AccountMap) CreateSmartContractAccountWithCodeHash ¶
func (am AccountMap) CreateSmartContractAccountWithCodeHash(owner []byte, address []byte, code []byte, codeHash []byte, world *MockWorld) *Account
CreateSmartContractAccountWithCodeHash instantiates an account for a smart contract with the given address and WASM bytecode.
func (AccountMap) DeleteAccount ¶
func (am AccountMap) DeleteAccount(address []byte)
DeleteAccount removes account based on address
func (AccountMap) GetAccount ¶
func (am AccountMap) GetAccount(address []byte) *Account
GetAccount retrieves account based on address
func (AccountMap) LoadAccountStorageFrom ¶
func (am AccountMap) LoadAccountStorageFrom(otherAM AccountMap) error
LoadAccountStorageFrom reassigns the storage of the accounts to the storage of the accounts found in otherAM; it only does a reference change, not a deep copy.
func (AccountMap) PutAccount ¶
func (am AccountMap) PutAccount(account *Account)
PutAccount inserts account based on address.
func (AccountMap) PutAccounts ¶
func (am AccountMap) PutAccounts(accounts []*Account)
PutAccounts inserts multiple accounts based on address.
type BlockInfo ¶
type BlockInfo struct {
BlockTimestamp uint64
BlockNonce uint64
BlockRound uint64
BlockEpoch uint32
RandomSeed *[48]byte
}
BlockInfo contains metadata about a mocked block
func (*BlockInfo) GetRandomSeedSlice ¶
GetRandomSeedSlice retrieves the configured random seed or a slice of zeros. Always 48 bytes long, never nil.
type BuiltinFunctionsWrapper ¶
type BuiltinFunctionsWrapper struct {
Container vmcommon.BuiltInFunctionContainer
MapDNSAddresses map[string]struct{}
World *MockWorld
Marshalizer vmcommon.Marshalizer
}
BuiltinFunctionsWrapper manages and initializes a BuiltInFunctionContainer along with its dependencies
func NewBuiltinFunctionsWrapper ¶
func NewBuiltinFunctionsWrapper( world *MockWorld, gasMap config.GasScheduleMap, ) (*BuiltinFunctionsWrapper, error)
NewBuiltinFunctionsWrapper creates a new BuiltinFunctionsWrapper with default dependencies.
func (*BuiltinFunctionsWrapper) GetBuiltinFunctionNames ¶
func (bf *BuiltinFunctionsWrapper) GetBuiltinFunctionNames() vmcommon.FunctionNames
GetBuiltinFunctionNames returns the list of defined builtin-in functions.
func (*BuiltinFunctionsWrapper) GetTokenBalance ¶
func (bf *BuiltinFunctionsWrapper) GetTokenBalance(address []byte, tokenIdentifier []byte, nonce uint64) (*big.Int, error)
GetTokenBalance returns the ESDT balance of an account for the given token key (token keys are built from the token identifier using MakeTokenKey).
func (*BuiltinFunctionsWrapper) GetTokenData ¶
func (bf *BuiltinFunctionsWrapper) GetTokenData(address []byte, tokenIdentifier []byte, nonce uint64) (*esdt.ESDigitalToken, error)
GetTokenData gets the ESDT information related to a token from the storage of an account (token keys are built from the token identifier using MakeTokenKey).
func (*BuiltinFunctionsWrapper) PerformDirectESDTTransfer ¶
func (bf *BuiltinFunctionsWrapper) PerformDirectESDTTransfer( sender []byte, receiver []byte, token []byte, nonce uint64, value *big.Int, callType vm.CallType, gasLimit uint64, gasPrice uint64, ) (uint64, error)
PerformDirectESDTTransfer calls the real ESDTTransfer function immediately; only works for in-shard transfers for now, but it will be expanded to cross-shard. TODO rewrite to simulate what the SCProcessor does when executing a tx with data "ESDTTransfer@token@value@contractfunc@contractargs..." TODO this function duplicates code from host.ExecuteESDTTransfer(), must refactor
func (*BuiltinFunctionsWrapper) PerformDirectMultiESDTTransfer ¶
func (bf *BuiltinFunctionsWrapper) PerformDirectMultiESDTTransfer( sender []byte, receiver []byte, esdtTransfers []*mj.ESDTTxData, callType vm.CallType, gasLimit uint64, gasPrice uint64, ) (uint64, error)
PerformDirectMultiESDTTransfer -
func (*BuiltinFunctionsWrapper) ProcessBuiltInFunction ¶
func (bf *BuiltinFunctionsWrapper) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
ProcessBuiltInFunction delegates the execution of a real builtin function to the inner BuiltInFunctionContainer.
func (*BuiltinFunctionsWrapper) SetTokenData ¶
func (bf *BuiltinFunctionsWrapper) SetTokenData(address []byte, tokenIdentifier []byte, nonce uint64, tokenData *esdt.ESDigitalToken) error
SetTokenData sets the ESDT information related to a token from the storage of an account (token keys are built from the token identifier using MakeTokenKey).
type EnableEpochsHandlerStub ¶
type EnableEpochsHandlerStub struct {
CheckExecuteReadOnlyEnableEpochField uint32
CreateNFTThroughExecByCallerEnableEpochField uint32
DisableExecByCallerEnableEpochField uint32
FixFailExecutionOnErrorEnableEpochField uint32
FixOOGReturnCodeEnableEpochField uint32
IsAheadOfTimeGasUsageFlagEnabledField bool
IsBuiltInFunctionsFlagEnabledField bool
IsCheckCorrectTokenIDForTransferRoleFlagEnabledField bool
IsCheckExecuteOnReadOnlyFlagEnabledField bool
IsCheckFrozenCollectionFlagEnabledField bool
IsCheckFunctionArgumentFlagEnabledField bool
IsCheckTransferFlagEnabledField bool
IsCreateNFTThroughExecByCallerFlagEnabledField bool
IsDisableExecByCallerFlagEnabledField bool
IsESDTNFTImprovementV1FlagEnabledField bool
IsESDTTransferRoleFlagEnabledField bool
IsFailExecutionOnEveryAPIErrorFlagEnabledField bool
IsFixAsyncCallbackCheckFlagEnabledField bool
IsFixOOGReturnCodeFlagEnabledField bool
IsFixOldTokenLiquidityEnabledField bool
IsGlobalMintBurnFlagEnabledField bool
IsManagedCryptoAPIsFlagEnabledField bool
IsMultiESDTTransferFixOnCallBackFlagEnabledField bool
IsRefactorContextFlagEnabledField bool
IsRemoveNonUpdatedStorageFlagEnabledField bool
IsRepairCallbackFlagEnabledField bool
IsSCDeployFlagEnabledField bool
IsSaveToSystemAccountFlagEnabledField bool
IsSendAlwaysFlagEnabledField bool
IsStorageAPICostOptimizationFlagEnabledField bool
IsTransferToMetaFlagEnabledField bool
IsValueLengthCheckFlagEnabledField bool
ManagedCryptoAPIEnableEpochField uint32
MultiESDTTransferAsyncCallBackEnableEpochField uint32
RefactorContextEnableEpochField uint32
RemoveNonUpdatedStorageEnableEpochField uint32
StorageAPICostOptimizationEnableEpochField uint32
IsRuntimeMemStoreLimitEnabledField bool
IsMaxBlockchainHookCountersFlagEnabledField bool
IsWipeSingleNFTLiquidityDecreaseEnabledField bool
IsAlwaysSaveTokenMetaDataEnabledField bool
}
EnableEpochsHandlerStub -
func EnableEpochsHandlerStubAllFlags ¶
func EnableEpochsHandlerStubAllFlags() *EnableEpochsHandlerStub
EnableEpochsHandlerStubAllFlags creates a new EnableEpochsHandlerStub with all flags enabled
func EnableEpochsHandlerStubNoFlags ¶
func EnableEpochsHandlerStubNoFlags() *EnableEpochsHandlerStub
EnableEpochsHandlerStubNoFlags creates a new EnableEpochsHandlerStub with all flags disabled
func (*EnableEpochsHandlerStub) CheckExecuteReadOnlyEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) CheckExecuteReadOnlyEnableEpoch() uint32
CheckExecuteReadOnlyEnableEpoch -
func (*EnableEpochsHandlerStub) CreateNFTThroughExecByCallerEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) CreateNFTThroughExecByCallerEnableEpoch() uint32
CreateNFTThroughExecByCallerEnableEpoch -
func (*EnableEpochsHandlerStub) DisableExecByCallerEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) DisableExecByCallerEnableEpoch() uint32
DisableExecByCallerEnableEpoch -
func (*EnableEpochsHandlerStub) FixFailExecutionOnErrorEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) FixFailExecutionOnErrorEnableEpoch() uint32
FixFailExecutionOnErrorEnableEpoch -
func (*EnableEpochsHandlerStub) FixOOGReturnCodeEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) FixOOGReturnCodeEnableEpoch() uint32
FixOOGReturnCodeEnableEpoch -
func (*EnableEpochsHandlerStub) IsAheadOfTimeGasUsageFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsAheadOfTimeGasUsageFlagEnabled() bool
IsAheadOfTimeGasUsageFlagEnabled -
func (*EnableEpochsHandlerStub) IsAlwaysSaveTokenMetaDataEnabled ¶
func (stub *EnableEpochsHandlerStub) IsAlwaysSaveTokenMetaDataEnabled() bool
IsAlwaysSaveTokenMetaDataEnabled -
func (*EnableEpochsHandlerStub) IsBuiltInFunctionsFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsBuiltInFunctionsFlagEnabled() bool
IsBuiltInFunctionsFlagEnabled -
func (*EnableEpochsHandlerStub) IsCheckCorrectTokenIDForTransferRoleFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsCheckCorrectTokenIDForTransferRoleFlagEnabled() bool
IsCheckCorrectTokenIDForTransferRoleFlagEnabled -
func (*EnableEpochsHandlerStub) IsCheckExecuteOnReadOnlyFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsCheckExecuteOnReadOnlyFlagEnabled() bool
IsCheckExecuteOnReadOnlyFlagEnabled -
func (*EnableEpochsHandlerStub) IsCheckFrozenCollectionFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsCheckFrozenCollectionFlagEnabled() bool
IsCheckFrozenCollectionFlagEnabled -
func (*EnableEpochsHandlerStub) IsCheckFunctionArgumentFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsCheckFunctionArgumentFlagEnabled() bool
IsCheckFunctionArgumentFlagEnabled -
func (*EnableEpochsHandlerStub) IsCheckTransferFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsCheckTransferFlagEnabled() bool
IsCheckTransferFlagEnabled -
func (*EnableEpochsHandlerStub) IsCreateNFTThroughExecByCallerFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsCreateNFTThroughExecByCallerFlagEnabled() bool
IsCreateNFTThroughExecByCallerFlagEnabled -
func (*EnableEpochsHandlerStub) IsDisableExecByCallerFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsDisableExecByCallerFlagEnabled() bool
IsDisableExecByCallerFlagEnabled -
func (*EnableEpochsHandlerStub) IsESDTNFTImprovementV1FlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsESDTNFTImprovementV1FlagEnabled() bool
IsESDTNFTImprovementV1FlagEnabled -
func (*EnableEpochsHandlerStub) IsESDTTransferRoleFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsESDTTransferRoleFlagEnabled() bool
IsESDTTransferRoleFlagEnabled -
func (*EnableEpochsHandlerStub) IsFailExecutionOnEveryAPIErrorFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsFailExecutionOnEveryAPIErrorFlagEnabled() bool
IsFailExecutionOnEveryAPIErrorFlagEnabled -
func (*EnableEpochsHandlerStub) IsFixAsyncCallbackCheckFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsFixAsyncCallbackCheckFlagEnabled() bool
IsFixAsyncCallbackCheckFlagEnabled -
func (*EnableEpochsHandlerStub) IsFixOOGReturnCodeFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsFixOOGReturnCodeFlagEnabled() bool
IsFixOOGReturnCodeFlagEnabled -
func (*EnableEpochsHandlerStub) IsFixOldTokenLiquidityEnabled ¶
func (stub *EnableEpochsHandlerStub) IsFixOldTokenLiquidityEnabled() bool
IsFixOldTokenLiquidityEnabled -
func (*EnableEpochsHandlerStub) IsGlobalMintBurnFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsGlobalMintBurnFlagEnabled() bool
IsGlobalMintBurnFlagEnabled -
func (*EnableEpochsHandlerStub) IsInterfaceNil ¶
func (stub *EnableEpochsHandlerStub) IsInterfaceNil() bool
IsInterfaceNil -
func (*EnableEpochsHandlerStub) IsManagedCryptoAPIsFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsManagedCryptoAPIsFlagEnabled() bool
IsManagedCryptoAPIsFlagEnabled -
func (*EnableEpochsHandlerStub) IsMaxBlockchainHookCountersFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsMaxBlockchainHookCountersFlagEnabled() bool
IsMaxBlockchainHookCountersFlagEnabled -
func (*EnableEpochsHandlerStub) IsMultiESDTTransferFixOnCallBackFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsMultiESDTTransferFixOnCallBackFlagEnabled() bool
IsMultiESDTTransferFixOnCallBackFlagEnabled -
func (*EnableEpochsHandlerStub) IsRefactorContextFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsRefactorContextFlagEnabled() bool
IsRefactorContextFlagEnabled -
func (*EnableEpochsHandlerStub) IsRemoveNonUpdatedStorageFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsRemoveNonUpdatedStorageFlagEnabled() bool
IsRemoveNonUpdatedStorageFlagEnabled -
func (*EnableEpochsHandlerStub) IsRepairCallbackFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsRepairCallbackFlagEnabled() bool
IsRepairCallbackFlagEnabled -
func (*EnableEpochsHandlerStub) IsRuntimeMemStoreLimitEnabled ¶
func (stub *EnableEpochsHandlerStub) IsRuntimeMemStoreLimitEnabled() bool
IsRuntimeMemStoreLimitEnabled -
func (*EnableEpochsHandlerStub) IsSCDeployFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsSCDeployFlagEnabled() bool
IsSCDeployFlagEnabled -
func (*EnableEpochsHandlerStub) IsSaveToSystemAccountFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsSaveToSystemAccountFlagEnabled() bool
IsSaveToSystemAccountFlagEnabled -
func (*EnableEpochsHandlerStub) IsSendAlwaysFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsSendAlwaysFlagEnabled() bool
IsSendAlwaysFlagEnabled -
func (*EnableEpochsHandlerStub) IsStorageAPICostOptimizationFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsStorageAPICostOptimizationFlagEnabled() bool
IsStorageAPICostOptimizationFlagEnabled -
func (*EnableEpochsHandlerStub) IsTransferToMetaFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsTransferToMetaFlagEnabled() bool
IsTransferToMetaFlagEnabled -
func (*EnableEpochsHandlerStub) IsValueLengthCheckFlagEnabled ¶
func (stub *EnableEpochsHandlerStub) IsValueLengthCheckFlagEnabled() bool
IsValueLengthCheckFlagEnabled -
func (*EnableEpochsHandlerStub) IsWipeSingleNFTLiquidityDecreaseEnabled ¶
func (stub *EnableEpochsHandlerStub) IsWipeSingleNFTLiquidityDecreaseEnabled() bool
IsWipeSingleNFTLiquidityDecreaseEnabled -
func (*EnableEpochsHandlerStub) ManagedCryptoAPIEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) ManagedCryptoAPIEnableEpoch() uint32
ManagedCryptoAPIEnableEpoch -
func (*EnableEpochsHandlerStub) MultiESDTTransferAsyncCallBackEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) MultiESDTTransferAsyncCallBackEnableEpoch() uint32
MultiESDTTransferAsyncCallBackEnableEpoch -
func (*EnableEpochsHandlerStub) RefactorContextEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) RefactorContextEnableEpoch() uint32
RefactorContextEnableEpoch -
func (*EnableEpochsHandlerStub) RemoveNonUpdatedStorageEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) RemoveNonUpdatedStorageEnableEpoch() uint32
RemoveNonUpdatedStorageEnableEpoch -
func (*EnableEpochsHandlerStub) StorageAPICostOptimizationEnableEpoch ¶
func (stub *EnableEpochsHandlerStub) StorageAPICostOptimizationEnableEpoch() uint32
StorageAPICostOptimizationEnableEpoch -
type MockAccountsAdapter ¶
type MockAccountsAdapter struct {
World *MockWorld
Snapshots []AccountMap
}
MockAccountsAdapter is an implementation of AccountsAdapter based on MockWorld and the accounts within it.
func NewMockAccountsAdapter ¶
func NewMockAccountsAdapter(world *MockWorld) *MockAccountsAdapter
NewMockAccountsAdapter instantiates a new MockAccountsAdapter.
func (*MockAccountsAdapter) Commit ¶
func (m *MockAccountsAdapter) Commit() ([]byte, error)
Commit -
func (*MockAccountsAdapter) GetCode ¶
func (m *MockAccountsAdapter) GetCode(codeHash []byte) []byte
GetCode -
func (*MockAccountsAdapter) GetExistingAccount ¶
func (m *MockAccountsAdapter) GetExistingAccount(address []byte) (vmcommon.AccountHandler, error)
GetExistingAccount -
func (*MockAccountsAdapter) GetNumCheckpoints ¶
func (m *MockAccountsAdapter) GetNumCheckpoints() uint32
GetNumCheckpoints -
func (*MockAccountsAdapter) IsInterfaceNil ¶
func (m *MockAccountsAdapter) IsInterfaceNil() bool
IsInterfaceNil -
func (*MockAccountsAdapter) IsPruningEnabled ¶
func (m *MockAccountsAdapter) IsPruningEnabled() bool
IsPruningEnabled -
func (*MockAccountsAdapter) JournalLen ¶
func (m *MockAccountsAdapter) JournalLen() int
JournalLen -
func (*MockAccountsAdapter) LoadAccount ¶
func (m *MockAccountsAdapter) LoadAccount(address []byte) (vmcommon.AccountHandler, error)
LoadAccount -
func (*MockAccountsAdapter) RecreateTrie ¶
func (m *MockAccountsAdapter) RecreateTrie(_ []byte) error
RecreateTrie -
func (*MockAccountsAdapter) RemoveAccount ¶
func (m *MockAccountsAdapter) RemoveAccount(address []byte) error
RemoveAccount -
func (*MockAccountsAdapter) RevertToSnapshot ¶
func (m *MockAccountsAdapter) RevertToSnapshot(snapshotIndex int) error
RevertToSnapshot -
func (*MockAccountsAdapter) RootHash ¶
func (m *MockAccountsAdapter) RootHash() ([]byte, error)
RootHash -
func (*MockAccountsAdapter) SaveAccount ¶
func (m *MockAccountsAdapter) SaveAccount(account vmcommon.AccountHandler) error
SaveAccount -
func (*MockAccountsAdapter) SetStateCheckpoint ¶
func (m *MockAccountsAdapter) SetStateCheckpoint(_ []byte, _ context.Context)
SetStateCheckpoint -
func (*MockAccountsAdapter) SnapshotState ¶
func (m *MockAccountsAdapter) SnapshotState(_ []byte, _ context.Context)
SnapshotState -
type MockWorld ¶
type MockWorld struct {
SelfShardID uint32
AcctMap AccountMap
AccountsAdapter vmcommon.AccountsAdapter
PreviousBlockInfo *BlockInfo
CurrentBlockInfo *BlockInfo
Blockhashes [][]byte
NewAddressMocks []*NewAddressMock
StateRootHash []byte
Err error
LastCreatedContractAddress []byte
CompiledCode map[string][]byte
BuiltinFuncs *BuiltinFunctionsWrapper
IsPausedValue bool
IsLimitedTransferValue bool
ProvidedBlockchainHook vmcommon.BlockchainHook
OtherVMOutputMap map[string]*vmcommon.VMOutput
}
MockWorld provides a mock representation of the blockchain to be used in VM tests.
func (*MockWorld) ClearCompiledCodes ¶
func (b *MockWorld) ClearCompiledCodes()
ClearCompiledCodes -
func (*MockWorld) CommunicationIdentifier ¶
CommunicationIdentifier -
func (*MockWorld) CurrentEpoch ¶
CurrentEpoch returns the current epoch
func (*MockWorld) CurrentNonce ¶
CurrentNonce returns the nonce from the current block
func (*MockWorld) CurrentRandomSeed ¶
CurrentRandomSeed returns the random seed from the current header
func (*MockWorld) CurrentRound ¶
CurrentRound returns the round from the current block
func (*MockWorld) CurrentTimeStamp ¶
CurrentTimeStamp return the timestamp from the current block
func (*MockWorld) ExecuteSmartContractCallOnOtherVM ¶
func (b *MockWorld) ExecuteSmartContractCallOnOtherVM(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
ExecuteSmartContractCallOnOtherVM -
func (*MockWorld) GetAllState ¶
GetAllState simply returns the storage as-is.
func (*MockWorld) GetBlockhash ¶
GetBlockhash should return the hash of the nth previous blockchain. Offset specifies how many blocks we need to look back.
func (*MockWorld) GetBuiltinFunctionNames ¶
func (b *MockWorld) GetBuiltinFunctionNames() vmcommon.FunctionNames
GetBuiltinFunctionNames -
func (*MockWorld) GetCode ¶
func (b *MockWorld) GetCode(acc vmcommon.UserAccountHandler) []byte
GetCode retrieves the code from the given account, or nil if not found
func (*MockWorld) GetCompiledCode ¶
GetCompiledCode -
func (*MockWorld) GetESDTToken ¶
func (b *MockWorld) GetESDTToken(address []byte, tokenIdentifier []byte, nonce uint64) (*esdt.ESDigitalToken, error)
GetESDTToken -
func (*MockWorld) GetShardOfAddress ¶
GetShardOfAddress -
func (*MockWorld) GetStateRootHash ¶
GetStateRootHash returns the state root hash from the last committed block
func (*MockWorld) GetStorageData ¶
GetStorageData yields the storage value for a certain account and storage key. Should return an empty byte array if the key is missing from the account storage
func (*MockWorld) GetUserAccount ¶
func (b *MockWorld) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
GetUserAccount retrieves account info from map, or error if not found.
func (*MockWorld) InitBuiltinFunctions ¶
func (b *MockWorld) InitBuiltinFunctions(gasMap config.GasScheduleMap) error
InitBuiltinFunctions initializes the inner BuiltinFunctionsWrapper, required for calling builtin functions.
func (*MockWorld) IsInterfaceNil ¶
IsInterfaceNil returns true if underlying implementation is nil
func (*MockWorld) IsLimitedTransfer ¶
IsLimitedTransfer -
func (*MockWorld) IsSmartContract ¶
IsSmartContract -
func (*MockWorld) LastRandomSeed ¶
LastRandomSeed returns the random seed from the last committed block
func (*MockWorld) LastTimeStamp ¶
LastTimeStamp returns the timeStamp from the last committed block
func (*MockWorld) NewAddress ¶
func (b *MockWorld) NewAddress(creatorAddress []byte, creatorNonce uint64, _ []byte) ([]byte, error)
NewAddress provides the address for a new account. It looks up the explicit new address mocks, if none found generates one using a fake but realistic algorithm.
func (*MockWorld) ProcessBuiltInFunction ¶
func (b *MockWorld) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
ProcessBuiltInFunction -
func (*MockWorld) RevertToSnapshot ¶
RevertToSnapshot -
func (*MockWorld) RollbackChanges ¶
RollbackChanges should be called after the VM test has run, if the tx has failed
func (*MockWorld) SaveCompiledCode ¶
SaveCompiledCode -
func (*MockWorld) SetCurrentBlockHash ¶
SetCurrentBlockHash -
func (*MockWorld) SetProvidedBlockchainHook ¶
func (b *MockWorld) SetProvidedBlockchainHook(bh vmcommon.BlockchainHook)
SetProvidedBlockchainHook -
func (*MockWorld) UpdateAccountFromOutputAccount ¶
func (b *MockWorld) UpdateAccountFromOutputAccount(modAcct *vmcommon.OutputAccount)
UpdateAccountFromOutputAccount updates a single account from a transaction output.
func (*MockWorld) UpdateAccounts ¶
func (b *MockWorld) UpdateAccounts( outputAccounts map[string]*vmcommon.OutputAccount, accountsToDelete [][]byte) error
UpdateAccounts should be called after the VM test has run, to update world state
func (*MockWorld) UpdateBalance ¶
UpdateBalance sets a new balance to an account
func (*MockWorld) UpdateBalanceWithDelta ¶
UpdateBalanceWithDelta changes balance of an account by a given amount
type NewAddressMock ¶
NewAddressMock allows tests to specify what new addresses to generate