Documentation ¶
Index ¶
- Variables
- func GenerateMockAddress(creatorAddress []byte, creatorNonce uint64) []byte
- func GetTokenNameFromKey(key []byte) []byte
- func IsESDTKey(key []byte) bool
- func IsNonceKey(key []byte) bool
- func IsRoleKey(key []byte) bool
- func IsTokenKey(key []byte) bool
- func MakeLastNonceKey(tokenName []byte) []byte
- func MakeTokenKey(tokenName []byte, nonce uint64) []byte
- func MakeTokenRolesKey(tokenName []byte) []byte
- type Account
- 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) DataTrie() data.Trie
- func (a *Account) DataTrieTracker() state.DataTrieTracker
- 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) GetFullMockESDTData() (map[string]*MockESDTData, error)
- func (a *Account) GetNonce() uint64
- func (a *Account) GetOwnerAddress() []byte
- func (a *Account) GetRootHash() []byte
- func (a *Account) GetTokenBalance(tokenKey []byte) (*big.Int, error)
- func (a *Account) GetTokenBalanceByName(tokenName string) (*big.Int, error)
- func (a *Account) GetTokenData(tokenKey []byte) (*esdt.ESDigitalToken, error)
- func (a *Account) GetTokenKeys() [][]byte
- func (a *Account) GetTokenRoles(tokenName []byte) ([][]byte, error)
- func (a *Account) GetUserName() []byte
- func (a *Account) IncreaseNonce(nonce uint64)
- func (a *Account) IsInterfaceNil() bool
- func (a *Account) RetrieveValue(key []byte) ([]byte, 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) SetDataTrie(tr data.Trie)
- func (a *Account) SetLastNonce(tokenName []byte, lastNonce uint64) error
- func (a *Account) SetLastNonces(lastNonces map[string]uint64) error
- func (a *Account) SetOwnerAddress(address []byte)
- func (a *Account) SetRootHash(hash []byte)
- func (a *Account) SetTokenBalance(tokenKey []byte, balance *big.Int) error
- func (a *Account) SetTokenData(tokenKey []byte, tokenData *esdt.ESDigitalToken) error
- func (a *Account) SetTokenRoles(tokenName []byte, roles [][]byte) error
- func (a *Account) SetTokenRolesAsStrings(tokenName []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
- type AccountMap
- func (am AccountMap) Clone() AccountMap
- func (am AccountMap) CreateAccount(address []byte) *Account
- func (am AccountMap) CreateSmartContractAccount(owner []byte, address []byte, code []byte) *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, tokenKey []byte) (*big.Int, error)
- func (bf *BuiltinFunctionsWrapper) GetTokenData(address []byte, tokenKey []byte) (*esdt.ESDigitalToken, error)
- func (bf *BuiltinFunctionsWrapper) PerformDirectESDTTransfer(sender []byte, receiver []byte, token []byte, nonce uint64, value *big.Int, ...) (uint64, error)
- func (bf *BuiltinFunctionsWrapper) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
- func (bf *BuiltinFunctionsWrapper) SetTokenBalance(address []byte, tokenKey []byte, balance *big.Int) error
- func (bf *BuiltinFunctionsWrapper) SetTokenData(address []byte, tokenKey []byte, tokenData *esdt.ESDigitalToken) error
- type MockAccountsAdapter
- func (m *MockAccountsAdapter) CancelPrune(_ []byte, _ data.TriePruningIdentifier)
- func (m *MockAccountsAdapter) Commit() ([]byte, error)
- func (m *MockAccountsAdapter) GetAllLeaves(_ []byte, _ context.Context) (chan core.KeyValueHolder, error)
- func (m *MockAccountsAdapter) GetCode(codeHash []byte) []byte
- func (m *MockAccountsAdapter) GetExistingAccount(address []byte) (state.AccountHandler, error)
- func (m *MockAccountsAdapter) GetNumCheckpoints() uint32
- func (m *MockAccountsAdapter) GetTrie(_ []byte) (data.Trie, error)
- func (m *MockAccountsAdapter) IsInterfaceNil() bool
- func (m *MockAccountsAdapter) IsPruningEnabled() bool
- func (m *MockAccountsAdapter) JournalLen() int
- func (m *MockAccountsAdapter) LoadAccount(address []byte) (state.AccountHandler, error)
- func (m *MockAccountsAdapter) PruneTrie(_ []byte, _ data.TriePruningIdentifier)
- func (m *MockAccountsAdapter) RecreateAllTries(_ []byte, _ context.Context) (map[string]data.Trie, 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 state.AccountHandler) error
- func (m *MockAccountsAdapter) SetStateCheckpoint(_ []byte, _ context.Context)
- func (m *MockAccountsAdapter) SnapshotState(_ []byte, _ context.Context)
- type MockESDTData
- 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) 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, tokenName []byte, nonce uint64) (*esdt.ESDigitalToken, error)
- func (b *MockWorld) GetShardOfAddress(address []byte) uint32
- func (b *MockWorld) GetStateRootHash() []byte
- func (b *MockWorld) GetStorageData(accountAddress []byte, key []byte) ([]byte, 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) IsPayable(address []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) 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) 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 ¶
This section is empty.
Variables ¶
var ESDTNonceKeyPrefix = []byte(core.ElrondProtectedKeyPrefix + core.ESDTNFTLatestNonceIdentifier)
ESDTNonceKeyPrefix is the prefix of storage keys belonging to ESDT nonces.
var ESDTRoleKeyPrefix = []byte(core.ElrondProtectedKeyPrefix + core.ESDTRoleIdentifier + core.ESDTKeyIdentifier)
ESDTRoleKeyPrefix is the prefix of storage keys belonging to ESDT roles.
var ESDTTokenKeyPrefix = []byte(core.ElrondProtectedKeyPrefix + core.ESDTKeyIdentifier)
ESDTTokenKeyPrefix is the prefix of storage keys belonging to ESDT tokens.
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 ErrInvalidAddressLength = errors.New("invalid address length")
ErrInvalidAddressLength indicates an incorrect length given for an address.
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 GetTokenNameFromKey ¶ added in v1.2.5
GetTokenNameFromKey extracts the token name from the given storage key; it does not check whether the key is indeed a token key or not.
func IsNonceKey ¶ added in v1.2.5
IsNonceKey returns true if the given storage key belongs to an ESDT nonce.
func IsRoleKey ¶ added in v1.2.5
IsRoleKey returns true if the given storage key belongs to an ESDT role.
func IsTokenKey ¶ added in v1.2.5
IsTokenKey returns true if the given storage key belongs to an ESDT token.
func MakeLastNonceKey ¶ added in v1.2.5
MakeLastNonceKey creates the storage key corresponding to the last nonce of the given tokenName.
func MakeTokenKey ¶ added in v1.2.5
MakeTokenKey creates the storage key corresponding to the given tokenName.
func MakeTokenRolesKey ¶ added in v1.2.5
MakeTokenRolesKey creates the storage key corresponding to the roles for the given tokenName.
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 }
Account holds the account info
func (*Account) AddToBalance ¶ added in v1.2.5
AddToBalance -
func (*Account) AddToDeveloperReward ¶ added in v1.2.5
AddToDeveloperReward -
func (*Account) ChangeOwnerAddress ¶ added in v1.2.5
ChangeOwnerAddress -
func (*Account) ClaimDeveloperRewards ¶ added in v1.2.5
ClaimDeveloperRewards -
func (*Account) ClearDataCaches ¶ added in v1.2.5
func (a *Account) ClearDataCaches()
ClearDataCaches -
func (*Account) DataTrieTracker ¶ added in v1.2.5
func (a *Account) DataTrieTracker() state.DataTrieTracker
DataTrieTracker -
func (*Account) GetDeveloperReward ¶
GetDeveloperReward -
func (*Account) GetFullMockESDTData ¶ added in v1.2.9
func (a *Account) GetFullMockESDTData() (map[string]*MockESDTData, error)
GetFullMockESDTData returns the information about all the ESDT tokens held by the account.
func (*Account) GetTokenBalance ¶ added in v1.2.5
GetTokenBalance returns the ESDT balance of the account, specified by the token key.
func (*Account) GetTokenBalanceByName ¶ added in v1.2.5
GetTokenBalanceByName returns the ESDT balance of the account, specified by the token name.
func (*Account) GetTokenData ¶ added in v1.2.5
func (a *Account) GetTokenData(tokenKey []byte) (*esdt.ESDigitalToken, error)
GetTokenData gets the ESDT information related to a token from the storage of the account.
func (*Account) GetTokenKeys ¶ added in v1.2.5
GetTokenKeys returns the storage keys of all the ESDT tokens owned by the account.
func (*Account) GetTokenRoles ¶ added in v1.2.5
GetTokenRoles returns the roles of the account for the specified tokenName.
func (*Account) IncreaseNonce ¶ added in v1.2.5
IncreaseNonce -
func (*Account) RetrieveValue ¶ added in v1.2.5
RetrieveValue -
func (*Account) SaveKeyValue ¶ added in v1.2.5
SaveKeyValue -
func (*Account) SetBalance ¶ added in v1.1.2
SetBalance -
func (*Account) SetCodeAndMetadata ¶ added in v1.2.5
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) SetCodeHash ¶ added in v1.2.5
SetCodeHash -
func (*Account) SetCodeMetadata ¶ added in v1.2.5
SetCodeMetadata -
func (*Account) SetDataTrie ¶ added in v1.2.5
SetDataTrie -
func (*Account) SetLastNonce ¶ added in v1.2.9
SetLastNonce writes the last nonce of a specified ESDT into the storage.
func (*Account) SetLastNonces ¶ added in v1.2.5
SetLastNonces writes the last nonces of each specified ESDT into the storage.
func (*Account) SetOwnerAddress ¶ added in v1.2.5
SetOwnerAddress -
func (*Account) SetRootHash ¶ added in v1.2.5
SetRootHash -
func (*Account) SetTokenBalance ¶ added in v1.2.5
SetTokenBalance sets the ESDT balance of the account, specified by the token key.
func (*Account) SetTokenData ¶ added in v1.2.5
func (a *Account) SetTokenData(tokenKey []byte, tokenData *esdt.ESDigitalToken) error
SetTokenData sets the ESDT information related to a token into the storage of the account.
func (*Account) SetTokenRoles ¶ added in v1.2.5
SetTokenRoles sets the specified roles to the account, corresponding to the given tokenName.
func (*Account) SetTokenRolesAsStrings ¶ added in v1.2.5
SetTokenRolesAsStrings sets the specified roles to the account, corresponding to the given tokenName.
func (*Account) SetUserName ¶ added in v1.2.5
SetUserName -
func (*Account) StorageValue ¶
StorageValue yields the storage value for key, default 0
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 ¶ added in v1.2.5
func (am AccountMap) Clone() AccountMap
Clone creates a deep clone of the entire AccountMap.
func (AccountMap) CreateAccount ¶ added in v1.1.2
func (am AccountMap) CreateAccount(address []byte) *Account
CreateAccount instantiates an empty account for the given address.
func (AccountMap) CreateSmartContractAccount ¶ added in v1.1.2
func (am AccountMap) CreateSmartContractAccount(owner []byte, address []byte, code []byte) *Account
CreateSmartContractAccount 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 ¶ added in v1.2.5
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
type BuiltinFunctionsWrapper ¶ added in v1.2.5
type BuiltinFunctionsWrapper struct { Container process.BuiltInFunctionContainer MapDNSAddresses map[string]struct{} World *MockWorld Marshalizer marshal.Marshalizer }
BuiltinFunctionsWrapper manages and initializes a BuiltInFunctionContainer along with its dependencies
func NewBuiltinFunctionsWrapper ¶ added in v1.2.5
func NewBuiltinFunctionsWrapper( world *MockWorld, gasMap config.GasScheduleMap, ) (*BuiltinFunctionsWrapper, error)
NewBuiltinFunctionsWrapper creates a new BuiltinFunctionsWrapper with default dependencies.
func (*BuiltinFunctionsWrapper) GetBuiltinFunctionNames ¶ added in v1.2.5
func (bf *BuiltinFunctionsWrapper) GetBuiltinFunctionNames() vmcommon.FunctionNames
GetBuiltinFunctionNames returns the list of defined builtin-in functions.
func (*BuiltinFunctionsWrapper) GetTokenBalance ¶ added in v1.2.5
func (bf *BuiltinFunctionsWrapper) GetTokenBalance(address []byte, tokenKey []byte) (*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 ¶ added in v1.2.5
func (bf *BuiltinFunctionsWrapper) GetTokenData(address []byte, tokenKey []byte) (*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 ¶ added in v1.2.5
func (bf *BuiltinFunctionsWrapper) PerformDirectESDTTransfer( sender []byte, receiver []byte, token []byte, nonce uint64, value *big.Int, callType vmcommon.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) ProcessBuiltInFunction ¶ added in v1.2.5
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) SetTokenBalance ¶ added in v1.2.5
func (bf *BuiltinFunctionsWrapper) SetTokenBalance(address []byte, tokenKey []byte, balance *big.Int) error
SetTokenBalance sets the ESDT balance of an account for the given token key (token keys are built from the token identifier using MakeTokenKey).
func (*BuiltinFunctionsWrapper) SetTokenData ¶ added in v1.2.5
func (bf *BuiltinFunctionsWrapper) SetTokenData(address []byte, tokenKey []byte, 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 MockAccountsAdapter ¶ added in v1.2.5
type MockAccountsAdapter struct { World *MockWorld Snapshots []AccountMap }
MockAccountsAdapter is an implementation of AccountsAdapter based on MockWorld and the accounts within it.
func NewMockAccountsAdapter ¶ added in v1.2.5
func NewMockAccountsAdapter(world *MockWorld) *MockAccountsAdapter
NewMockAccountsAdapter instantiates a new MockAccountsAdapter.
func (*MockAccountsAdapter) CancelPrune ¶ added in v1.2.5
func (m *MockAccountsAdapter) CancelPrune(_ []byte, _ data.TriePruningIdentifier)
CancelPrune -
func (*MockAccountsAdapter) Commit ¶ added in v1.2.5
func (m *MockAccountsAdapter) Commit() ([]byte, error)
Commit -
func (*MockAccountsAdapter) GetAllLeaves ¶ added in v1.2.5
func (m *MockAccountsAdapter) GetAllLeaves(_ []byte, _ context.Context) (chan core.KeyValueHolder, error)
GetAllLeaves -
func (*MockAccountsAdapter) GetCode ¶ added in v1.2.5
func (m *MockAccountsAdapter) GetCode(codeHash []byte) []byte
GetCode -
func (*MockAccountsAdapter) GetExistingAccount ¶ added in v1.2.5
func (m *MockAccountsAdapter) GetExistingAccount(address []byte) (state.AccountHandler, error)
GetExistingAccount -
func (*MockAccountsAdapter) GetNumCheckpoints ¶ added in v1.2.5
func (m *MockAccountsAdapter) GetNumCheckpoints() uint32
GetNumCheckpoints -
func (*MockAccountsAdapter) GetTrie ¶ added in v1.2.8
func (m *MockAccountsAdapter) GetTrie(_ []byte) (data.Trie, error)
GetTrie -
func (*MockAccountsAdapter) IsInterfaceNil ¶ added in v1.2.5
func (m *MockAccountsAdapter) IsInterfaceNil() bool
IsInterfaceNil -
func (*MockAccountsAdapter) IsPruningEnabled ¶ added in v1.2.5
func (m *MockAccountsAdapter) IsPruningEnabled() bool
IsPruningEnabled -
func (*MockAccountsAdapter) JournalLen ¶ added in v1.2.5
func (m *MockAccountsAdapter) JournalLen() int
JournalLen -
func (*MockAccountsAdapter) LoadAccount ¶ added in v1.2.5
func (m *MockAccountsAdapter) LoadAccount(address []byte) (state.AccountHandler, error)
LoadAccount -
func (*MockAccountsAdapter) PruneTrie ¶ added in v1.2.5
func (m *MockAccountsAdapter) PruneTrie(_ []byte, _ data.TriePruningIdentifier)
PruneTrie -
func (*MockAccountsAdapter) RecreateAllTries ¶ added in v1.2.5
func (m *MockAccountsAdapter) RecreateAllTries(_ []byte, _ context.Context) (map[string]data.Trie, error)
RecreateAllTries -
func (*MockAccountsAdapter) RecreateTrie ¶ added in v1.2.5
func (m *MockAccountsAdapter) RecreateTrie(_ []byte) error
RecreateTrie -
func (*MockAccountsAdapter) RemoveAccount ¶ added in v1.2.5
func (m *MockAccountsAdapter) RemoveAccount(address []byte) error
RemoveAccount -
func (*MockAccountsAdapter) RevertToSnapshot ¶ added in v1.2.5
func (m *MockAccountsAdapter) RevertToSnapshot(snapshotIndex int) error
RevertToSnapshot -
func (*MockAccountsAdapter) RootHash ¶ added in v1.2.5
func (m *MockAccountsAdapter) RootHash() ([]byte, error)
RootHash -
func (*MockAccountsAdapter) SaveAccount ¶ added in v1.2.5
func (m *MockAccountsAdapter) SaveAccount(account state.AccountHandler) error
SaveAccount -
func (*MockAccountsAdapter) SetStateCheckpoint ¶ added in v1.2.5
func (m *MockAccountsAdapter) SetStateCheckpoint(_ []byte, _ context.Context)
SetStateCheckpoint -
func (*MockAccountsAdapter) SnapshotState ¶ added in v1.2.5
func (m *MockAccountsAdapter) SnapshotState(_ []byte, _ context.Context)
SnapshotState -
type MockESDTData ¶ added in v1.2.9
type MockESDTData struct { TokenIdentifier []byte Instances []*esdt.ESDigitalToken LastNonce uint64 Roles [][]byte }
MockESDTData groups together all instances of a token (same token name, different nonces).
type MockWorld ¶
type MockWorld struct { SelfShardID uint32 AcctMap AccountMap AccountsAdapter state.AccountsAdapter PreviousBlockInfo *BlockInfo CurrentBlockInfo *BlockInfo Blockhashes [][]byte NewAddressMocks []*NewAddressMock StateRootHash []byte Err error LastCreatedContractAddress []byte CompiledCode map[string][]byte BuiltinFuncs *BuiltinFunctionsWrapper }
MockWorld provides a mock representation of the blockchain to be used in VM tests.
func (*MockWorld) ClearCompiledCodes ¶
func (b *MockWorld) ClearCompiledCodes()
ClearCompiledCodes -
func (*MockWorld) CommitChanges ¶ added in v1.2.5
CommitChanges -
func (*MockWorld) CommunicationIdentifier ¶ added in v1.2.5
CommunicationIdentifier -
func (*MockWorld) CreateStateBackup ¶ added in v1.2.5
func (b *MockWorld) CreateStateBackup()
CreateStateBackup -
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) 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 ¶ added in v1.0.2
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 ¶ added in v1.2.0
func (b *MockWorld) GetESDTToken(address []byte, tokenName []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 ¶ added in v1.2.5
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) 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) NumberOfShards ¶ added in v1.2.5
NumberOfShards -
func (*MockWorld) ProcessBuiltInFunction ¶
func (b *MockWorld) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
ProcessBuiltInFunction -
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) UpdateAccountFromOutputAccount ¶ added in v1.1.2
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