Documentation ¶
Index ¶
- func AccountAddress(i *big.Int) []byte
- func StorageKey(address []byte) string
- type Account
- func (a *Account) AddressBytes() []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) GetUserName() []byte
- func (a *Account) IsInterfaceNil() bool
- func (a *Account) StorageValue(key string) []byte
- type AccountMap
- type BlockInfo
- type BlockchainHookMock
- func (b *BlockchainHookMock) Clear()
- func (b *BlockchainHookMock) ClearCompiledCodes()
- func (b *BlockchainHookMock) CurrentEpoch() uint32
- func (b *BlockchainHookMock) CurrentNonce() uint64
- func (b *BlockchainHookMock) CurrentRandomSeed() []byte
- func (b *BlockchainHookMock) CurrentRound() uint64
- func (b *BlockchainHookMock) CurrentTimeStamp() uint64
- func (b *BlockchainHookMock) EnableMockAddressGeneration()
- func (b *BlockchainHookMock) GetAllState(_ []byte) (map[string][]byte, error)
- func (b *BlockchainHookMock) GetBlockhash(nonce uint64) ([]byte, error)
- func (b *BlockchainHookMock) GetBuiltinFunctionNames() vmcommon.FunctionNames
- func (b *BlockchainHookMock) GetCompiledCode(_ []byte) (bool, []byte)
- func (b *BlockchainHookMock) GetShardOfAddress(address []byte) uint32
- func (b *BlockchainHookMock) GetStateRootHash() []byte
- func (b *BlockchainHookMock) GetStorageData(accountAddress []byte, index []byte) ([]byte, error)
- func (b *BlockchainHookMock) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
- func (b *BlockchainHookMock) IsPayable(address []byte) (bool, error)
- func (b *BlockchainHookMock) IsSmartContract(address []byte) bool
- func (b *BlockchainHookMock) LastEpoch() uint32
- func (b *BlockchainHookMock) LastNonce() uint64
- func (b *BlockchainHookMock) LastRandomSeed() []byte
- func (b *BlockchainHookMock) LastRound() uint64
- func (b *BlockchainHookMock) LastTimeStamp() uint64
- func (b *BlockchainHookMock) NewAddress(creatorAddress []byte, creatorNonce uint64, _ []byte) ([]byte, error)
- func (b *BlockchainHookMock) ProcessBuiltInFunction(_ *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
- func (b *BlockchainHookMock) SaveCompiledCode(_ []byte, _ []byte)
- func (b *BlockchainHookMock) UpdateAccounts(modifiedAccounts []*vmi.OutputAccount, accountsToDelete [][]byte, ...) error
- func (b *BlockchainHookMock) UpdateBalance(address []byte, newBalance *big.Int) error
- func (b *BlockchainHookMock) UpdateBalanceWithDelta(address []byte, balanceDelta *big.Int) error
- func (b *BlockchainHookMock) UpdateWorldStateBefore(fromAddr []byte, gasLimit uint64, gasPrice uint64) error
- type NewAddressMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccountAddress ¶
AccountAddress converts to account address bytes from big.Int
func StorageKey ¶ added in v0.0.5
StorageKey builds a key for the mock
Types ¶
type Account ¶
type Account struct { Exists bool Address []byte Nonce uint64 Balance *big.Int BalanceDelta *big.Int Storage map[string][]byte Code []byte CodeMetadata []byte AsyncCallData string OwnerAddress []byte Username []byte ShardID uint32 IsSmartContract bool }
Account holds the account info
func (*Account) AddressBytes ¶ added in v0.3.2
AddressBytes -
func (*Account) GetCodeMetadata ¶ added in v0.3.2
GetCodeMetadata -
func (*Account) GetDeveloperReward ¶ added in v0.3.2
GetDeveloperReward -
func (*Account) GetOwnerAddress ¶ added in v0.3.2
GetOwnerAddress -
func (*Account) GetUserName ¶ added in v0.3.2
GetOwnerAddress -
func (*Account) IsInterfaceNil ¶ added in v0.3.2
IsInterfaceNil -
func (*Account) StorageValue ¶
StorageValue yields the storage value for key, default 0
type AccountMap ¶
AccountMap is a map from address to account
func NewAccountMap ¶
func NewAccountMap() AccountMap
NewAccountMap creates a new AccountMap instance
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) PutAccount ¶
func (am AccountMap) PutAccount(acct *Account)
PutAccount inserts account based on address
type BlockInfo ¶ added in v0.2.5
type BlockInfo struct { BlockTimestamp uint64 BlockNonce uint64 BlockRound uint64 BlockEpoch uint32 }
BlockInfo contains mock data about the corent block
type BlockchainHookMock ¶
type BlockchainHookMock struct { AcctMap AccountMap PreviousBlockInfo *BlockInfo CurrentBlockInfo *BlockInfo Blockhashes [][]byte NewAddressMocks []*NewAddressMock // contains filtered or unexported fields }
BlockchainHookMock provides a mock representation of the blockchain to be used in VM tests.
func (*BlockchainHookMock) Clear ¶
func (b *BlockchainHookMock) Clear()
Clear resets all mock data between tests.
func (*BlockchainHookMock) ClearCompiledCodes ¶ added in v0.4.4
func (b *BlockchainHookMock) ClearCompiledCodes()
func (*BlockchainHookMock) CurrentEpoch ¶ added in v0.0.4
func (b *BlockchainHookMock) CurrentEpoch() uint32
CurrentEpoch returns the current epoch
func (*BlockchainHookMock) CurrentNonce ¶ added in v0.0.4
func (b *BlockchainHookMock) CurrentNonce() uint64
CurrentNonce returns the nonce from the current block
func (*BlockchainHookMock) CurrentRandomSeed ¶ added in v0.0.4
func (b *BlockchainHookMock) CurrentRandomSeed() []byte
CurrentRandomSeed returns the random seed from the current header
func (*BlockchainHookMock) CurrentRound ¶ added in v0.0.4
func (b *BlockchainHookMock) CurrentRound() uint64
CurrentRound returns the round from the current block
func (*BlockchainHookMock) CurrentTimeStamp ¶ added in v0.0.4
func (b *BlockchainHookMock) CurrentTimeStamp() uint64
CurrentTimeStamp return the timestamp from the current block
func (*BlockchainHookMock) EnableMockAddressGeneration ¶ added in v0.0.5
func (b *BlockchainHookMock) EnableMockAddressGeneration()
EnableMockAddressGeneration causes the mock to generate its own new addresses.
func (*BlockchainHookMock) GetAllState ¶ added in v0.2.3
func (b *BlockchainHookMock) GetAllState(_ []byte) (map[string][]byte, error)
GetAllState -
func (*BlockchainHookMock) GetBlockhash ¶
func (b *BlockchainHookMock) GetBlockhash(nonce uint64) ([]byte, error)
GetBlockhash should return the hash of the nth previous blockchain. Offset specifies how many blocks we need to look back.
func (*BlockchainHookMock) GetBuiltinFunctionNames ¶ added in v0.1.8
func (b *BlockchainHookMock) GetBuiltinFunctionNames() vmcommon.FunctionNames
GetBuiltinFunctionNames -
func (*BlockchainHookMock) GetCompiledCode ¶ added in v0.4.3
func (b *BlockchainHookMock) GetCompiledCode(_ []byte) (bool, []byte)
func (*BlockchainHookMock) GetShardOfAddress ¶ added in v0.3.2
func (b *BlockchainHookMock) GetShardOfAddress(address []byte) uint32
GetShardOfAddress -
func (*BlockchainHookMock) GetStateRootHash ¶ added in v0.0.4
func (b *BlockchainHookMock) GetStateRootHash() []byte
GetStateRootHash returns the state root hash from the last committed block
func (*BlockchainHookMock) GetStorageData ¶
func (b *BlockchainHookMock) GetStorageData(accountAddress []byte, index []byte) ([]byte, error)
GetStorageData yields the storage value for a certain account and index. Should return an empty byte array if the key is missing from the account storage
func (*BlockchainHookMock) GetUserAccount ¶ added in v0.3.2
func (b *BlockchainHookMock) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error)
GetUserAccount retrieves account info from map, or error if not found.
func (*BlockchainHookMock) IsPayable ¶ added in v0.3.5
func (b *BlockchainHookMock) IsPayable(address []byte) (bool, error)
func (*BlockchainHookMock) IsSmartContract ¶ added in v0.3.2
func (b *BlockchainHookMock) IsSmartContract(address []byte) bool
IsSmartContract -
func (*BlockchainHookMock) LastEpoch ¶ added in v0.0.4
func (b *BlockchainHookMock) LastEpoch() uint32
LastEpoch returns the epoch from the last committed block
func (*BlockchainHookMock) LastNonce ¶ added in v0.0.4
func (b *BlockchainHookMock) LastNonce() uint64
LastNonce returns the nonce from from the last committed block
func (*BlockchainHookMock) LastRandomSeed ¶ added in v0.0.4
func (b *BlockchainHookMock) LastRandomSeed() []byte
LastRandomSeed returns the random seed from the last committed block
func (*BlockchainHookMock) LastRound ¶ added in v0.0.4
func (b *BlockchainHookMock) LastRound() uint64
LastRound returns the round from the last committed block
func (*BlockchainHookMock) LastTimeStamp ¶ added in v0.0.4
func (b *BlockchainHookMock) LastTimeStamp() uint64
LastTimeStamp returns the timeStamp from the last committed block
func (*BlockchainHookMock) NewAddress ¶
func (b *BlockchainHookMock) NewAddress(creatorAddress []byte, creatorNonce uint64, _ []byte) ([]byte, error)
NewAddress adapts between K model and elrond function
func (*BlockchainHookMock) ProcessBuiltInFunction ¶ added in v0.1.6
func (b *BlockchainHookMock) ProcessBuiltInFunction(_ *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
ProcessBuiltInFunction -
func (*BlockchainHookMock) SaveCompiledCode ¶ added in v0.4.3
func (b *BlockchainHookMock) SaveCompiledCode(_ []byte, _ []byte)
func (*BlockchainHookMock) UpdateAccounts ¶
func (b *BlockchainHookMock) UpdateAccounts( modifiedAccounts []*vmi.OutputAccount, accountsToDelete [][]byte, callerAddress []byte) error
UpdateAccounts should be called after the VM test has run, to update world state
func (*BlockchainHookMock) UpdateBalance ¶
func (b *BlockchainHookMock) UpdateBalance(address []byte, newBalance *big.Int) error
UpdateBalance sets a new balance to an account
func (*BlockchainHookMock) UpdateBalanceWithDelta ¶ added in v0.0.3
func (b *BlockchainHookMock) UpdateBalanceWithDelta(address []byte, balanceDelta *big.Int) error
UpdateBalanceWithDelta changes balance of an account by a given amount
func (*BlockchainHookMock) UpdateWorldStateBefore ¶
func (b *BlockchainHookMock) UpdateWorldStateBefore( fromAddr []byte, gasLimit uint64, gasPrice uint64) error
UpdateWorldStateBefore performs gas payment, before transaction
type NewAddressMock ¶ added in v0.2.2
NewAddressMock allows tests to specify what new addresses to generate