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
impl FakeExt
Sourcepub fn new_byzantium() -> Self
pub fn new_byzantium() -> Self
New fake externalities with byzantium schedule rules
Sourcepub fn new_constantinople() -> Self
pub fn new_constantinople() -> Self
New fake externalities with constantinople schedule rules
Sourcepub fn new_istanbul() -> Self
pub fn new_istanbul() -> Self
New fake externalities with Istanbul schedule rules
Sourcepub fn with_chain_id(self, chain_id: u64) -> Self
pub fn with_chain_id(self, chain_id: u64) -> Self
Set chain ID
Trait Implementations§
Source§impl Ext for FakeExt
impl Ext for FakeExt
Source§fn initial_storage_at(&self, _key: &H256) -> Result<H256>
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 exists_and_not_null(&self, address: &Address) -> Result<bool>
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>
fn origin_balance(&self) -> Result<U256>
Balance of the origin account.
Source§fn blockhash(&mut self, number: &U256) -> H256
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>
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>
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>>>
fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>
Returns code at given address
Source§fn extcodesize(&self, address: &Address) -> Result<Option<usize>>
fn extcodesize(&self, address: &Address) -> Result<Option<usize>>
Returns code size at given address
Source§fn extcodehash(&self, address: &Address) -> Result<Option<H256>>
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<()>
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>
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<()>
fn suicide(&mut self, refund_address: &Address) -> Result<()>
Should be called when contract commits suicide.
Address to which funds should be refunded.
Source§fn add_sstore_refund(&mut self, value: usize)
fn add_sstore_refund(&mut self, value: usize)
Increments sstore refunds counter.
Source§fn sub_sstore_refund(&mut self, value: usize)
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
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)>,
)
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)
fn trace_failed(&mut self)
Trace the execution failure of a single instruction.
Auto Trait Implementations§
impl Freeze for FakeExt
impl RefUnwindSafe for FakeExt
impl Send for FakeExt
impl Sync for FakeExt
impl Unpin for FakeExt
impl UnwindSafe for FakeExt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more