Struct FakeExt

Source
pub struct FakeExt {
Show 13 fields pub store: HashMap<H256, H256>, pub suicides: HashSet<Address>, pub calls: HashSet<FakeCall>, pub sstore_clears: i128, pub depth: usize, pub blockhashes: HashMap<U256, H256>, pub codes: HashMap<Address, Arc<Bytes>>, pub logs: Vec<FakeLogEntry>, pub info: EnvInfo, pub schedule: Schedule, pub balances: HashMap<Address, U256>, pub tracing: bool, pub is_static: bool, /* private fields */
}
Expand description

Fake externalities test structure.

Can’t do recursive calls.

Fields§

§store: HashMap<H256, H256>§suicides: HashSet<Address>§calls: HashSet<FakeCall>§sstore_clears: i128§depth: usize§blockhashes: HashMap<U256, H256>§codes: HashMap<Address, Arc<Bytes>>§logs: Vec<FakeLogEntry>§info: EnvInfo§schedule: Schedule§balances: HashMap<Address, U256>§tracing: bool§is_static: bool

Implementations§

Source§

impl FakeExt

Source

pub fn new() -> Self

New fake externalities

Source

pub fn new_byzantium() -> Self

New fake externalities with byzantium schedule rules

Source

pub fn new_constantinople() -> Self

New fake externalities with constantinople schedule rules

Source

pub fn new_istanbul() -> Self

New fake externalities with Istanbul schedule rules

Source

pub fn with_wasm(self) -> Self

Alter fake externalities to allow wasm

Source

pub fn with_chain_id(self, chain_id: u64) -> Self

Set chain ID

Trait Implementations§

Source§

impl Default for FakeExt

Source§

fn default() -> FakeExt

Returns the “default value” for a type. Read more
Source§

impl Ext for FakeExt

Source§

fn initial_storage_at(&self, _key: &H256) -> Result<H256>

Returns the storage value for a given key if reversion happens on the current transaction.
Source§

fn storage_at(&self, key: &H256) -> Result<H256>

Returns a value for given key.
Source§

fn set_storage(&mut self, key: H256, value: H256) -> Result<()>

Stores a value for given key.
Source§

fn exists(&self, address: &Address) -> Result<bool>

Determine whether an account exists.
Source§

fn exists_and_not_null(&self, address: &Address) -> Result<bool>

Determine whether an account exists and is not null (zero balance/nonce, no code).
Source§

fn origin_balance(&self) -> Result<U256>

Balance of the origin account.
Source§

fn balance(&self, address: &Address) -> Result<U256>

Returns address balance.
Source§

fn blockhash(&mut self, number: &U256) -> H256

Returns the hash of one of the 256 most recent complete blocks.
Source§

fn create( &mut self, gas: &U256, value: &U256, code: &[u8], _parent_version: &U256, address: CreateContractAddress, _trap: bool, ) -> Result<ContractCreateResult, TrapKind>

Creates new contract. Read more
Source§

fn call( &mut self, gas: &U256, sender_address: &Address, receive_address: &Address, value: Option<U256>, data: &[u8], code_address: &Address, _call_type: ActionType, _trap: bool, ) -> Result<MessageCallResult, TrapKind>

Message call. Read more
Source§

fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>

Returns code at given address
Source§

fn extcodesize(&self, address: &Address) -> Result<Option<usize>>

Returns code size at given address
Source§

fn extcodehash(&self, address: &Address) -> Result<Option<H256>>

Returns code hash at given address
Source§

fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> Result<()>

Creates log entry with given topics and data
Source§

fn ret( self, _gas: &U256, _data: &ReturnData, _apply_state: bool, ) -> Result<U256>

Should be called when transaction calls RETURN opcode. Returns gas_left if cost of returning the data is not too high.
Source§

fn suicide(&mut self, refund_address: &Address) -> Result<()>

Should be called when contract commits suicide. Address to which funds should be refunded.
Source§

fn schedule(&self) -> &Schedule

Returns schedule.
Source§

fn env_info(&self) -> &EnvInfo

Returns environment info.
Source§

fn chain_id(&self) -> u64

Returns the chain ID of the blockchain
Source§

fn depth(&self) -> usize

Returns current depth of execution. Read more
Source§

fn is_static(&self) -> bool

Check if running in static context.
Source§

fn add_sstore_refund(&mut self, value: usize)

Increments sstore refunds counter.
Source§

fn sub_sstore_refund(&mut self, value: usize)

Decrements sstore refunds counter.
Source§

fn trace_next_instruction( &mut self, _pc: usize, _instruction: u8, _gas: U256, ) -> bool

Decide if any more operations should be traced. Passthrough for the VM trace.
Source§

fn trace_prepare_execute( &mut self, _pc: usize, _instruction: u8, _gas_cost: U256, _mem_written: Option<(usize, usize)>, _store_written: Option<(U256, U256)>, )

Prepare to trace an operation. Passthrough for the VM trace. For each call of trace_prepare_execute either trace_failed or trace_executed MUST be called.
Source§

fn trace_failed(&mut self)

Trace the execution failure of a single instruction.
Source§

fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem: &[u8])

Trace the finalised execution of a single instruction.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V