pub struct FakeExt {Show 15 fields
pub initial_store: HashMap<H256, H256>,
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,
pub access_list: AccessList,
/* private fields */
}
Expand description
Fake externalities test structure.
Can’t do recursive calls.
Fields
initial_store: HashMap<H256, H256>
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
access_list: AccessList
Implementations
sourceimpl 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 new_berlin(from: Address, to: Address, builtins: &[Address]) -> Self
pub fn new_berlin(from: Address, to: Address, builtins: &[Address]) -> Self
New fake externalities with Berlin schedule rules
sourcepub fn new_london(from: Address, to: Address, builtins: &[Address]) -> Self
pub fn new_london(from: Address, to: Address, builtins: &[Address]) -> Self
New fake externalities with London 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
pub fn set_initial_storage(&mut self, key: H256, value: H256)
Trait Implementations
sourceimpl Ext for FakeExt
impl Ext for FakeExt
sourcefn 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.
sourcefn storage_at(&self, key: &H256) -> Result<H256>
fn storage_at(&self, key: &H256) -> Result<H256>
Returns a value for given key.
sourcefn 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).
sourcefn origin_balance(&self) -> Result<U256>
fn origin_balance(&self) -> Result<U256>
Balance of the origin account.
sourcefn 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.
sourcefn create(
&mut self,
gas: &U256,
value: &U256,
code: &[u8],
address: CreateContractAddress,
_trap: bool
) -> Result<ContractCreateResult, TrapKind>
fn create(
&mut self,
gas: &U256,
value: &U256,
code: &[u8],
address: CreateContractAddress,
_trap: bool
) -> Result<ContractCreateResult, TrapKind>
Creates new contract. Read more
sourcefn calc_address(
&self,
_code: &[u8],
_address: CreateContractAddress
) -> Option<Address>
fn calc_address(
&self,
_code: &[u8],
_address: CreateContractAddress
) -> Option<Address>
Returns the address that will be created in the create call
sourcefn call(
&mut self,
gas: &U256,
sender_address: &Address,
receive_address: &Address,
value: Option<U256>,
data: &[u8],
code_address: &Address,
_call_type: CallType,
_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: CallType,
_trap: bool
) -> Result<MessageCallResult, TrapKind>
Message call. Read more
sourcefn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>
fn extcode(&self, address: &Address) -> Result<Option<Arc<Bytes>>>
Returns code at given address
sourcefn extcodesize(&self, address: &Address) -> Result<Option<usize>>
fn extcodesize(&self, address: &Address) -> Result<Option<usize>>
Returns code size at given address
sourcefn extcodehash(&self, address: &Address) -> Result<Option<H256>>
fn extcodehash(&self, address: &Address) -> Result<Option<H256>>
Returns code hash at given address
sourcefn 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
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn add_sstore_refund(&mut self, value: usize)
fn add_sstore_refund(&mut self, value: usize)
Increments sstore refunds counter.
sourcefn sub_sstore_refund(&mut self, value: usize)
fn sub_sstore_refund(&mut self, value: usize)
Decrements sstore refunds counter.
sourcefn 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.
sourcefn al_is_enabled(&self) -> bool
fn al_is_enabled(&self) -> bool
Returns if the list is enabled
sourcefn al_contains_storage_key(&self, address: &Address, key: &H256) -> bool
fn al_contains_storage_key(&self, address: &Address, key: &H256) -> bool
Checks if contains an storage key
sourcefn al_insert_storage_key(&mut self, address: Address, key: H256)
fn al_insert_storage_key(&mut self, address: Address, key: H256)
Inserts an storage key into the list
sourcefn al_contains_address(&self, address: &Address) -> bool
fn al_contains_address(&self, address: &Address) -> bool
Checks if contains an address
sourcefn al_insert_address(&mut self, address: Address)
fn al_insert_address(&mut self, address: Address)
Inserts an address into the list
sourcefn 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. Read more
sourcefn trace_failed(&mut self)
fn trace_failed(&mut self)
Trace the execution failure of a single instruction.
Auto Trait Implementations
impl !RefUnwindSafe for FakeExt
impl !Send for FakeExt
impl !Sync for FakeExt
impl Unpin for FakeExt
impl !UnwindSafe for FakeExt
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more