Struct precompile_utils::testing::handle::MockHandle
source · pub struct MockHandle {
pub gas_limit: u64,
pub gas_used: u64,
pub logs: Vec<PrettyLog>,
pub subcall_handle: Option<SubcallHandle>,
pub code_address: H160,
pub input: Vec<u8>,
pub context: Context,
pub is_static: bool,
}
Expand description
Mock handle to write tests for precompiles.
Fields§
§gas_limit: u64
§gas_used: u64
§logs: Vec<PrettyLog>
§subcall_handle: Option<SubcallHandle>
§code_address: H160
§input: Vec<u8>
§context: Context
§is_static: bool
Implementations§
source§impl MockHandle
impl MockHandle
Trait Implementations§
source§impl PrecompileHandle for MockHandle
impl PrecompileHandle for MockHandle
source§fn call(
&mut self,
address: H160,
transfer: Option<Transfer>,
input: Vec<u8>,
target_gas: Option<u64>,
is_static: bool,
context: &Context
) -> (ExitReason, Vec<u8>)
fn call( &mut self, address: H160, transfer: Option<Transfer>, input: Vec<u8>, target_gas: Option<u64>, is_static: bool, context: &Context ) -> (ExitReason, Vec<u8>)
Perform subcall in provided context. Precompile specifies in which context the subcall is executed.
source§fn code_address(&self) -> H160
fn code_address(&self) -> H160
Retreive the code address (what is the address of the precompile being called).
source§fn record_cost(&mut self, cost: u64) -> Result<(), ExitError>
fn record_cost(&mut self, cost: u64) -> Result<(), ExitError>
Record cost to the Runtime gasometer.
source§fn remaining_gas(&self) -> u64
fn remaining_gas(&self) -> u64
Retreive the remaining gas.
source§fn log(
&mut self,
address: H160,
topics: Vec<H256>,
data: Vec<u8>
) -> Result<(), ExitError>
fn log( &mut self, address: H160, topics: Vec<H256>, data: Vec<u8> ) -> Result<(), ExitError>
Record a log.
Auto Trait Implementations§
impl !RefUnwindSafe for MockHandle
impl !Send for MockHandle
impl !Sync for MockHandle
impl Unpin for MockHandle
impl !UnwindSafe for MockHandle
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
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> PrecompileHandleExt for Twhere
T: PrecompileHandle,
impl<T> PrecompileHandleExt for Twhere
T: PrecompileHandle,
source§fn record_log_costs_manual(
&mut self,
topics: usize,
data_len: usize
) -> Result<(), PrecompileFailure>
fn record_log_costs_manual( &mut self, topics: usize, data_len: usize ) -> Result<(), PrecompileFailure>
Record cost of a log manualy. This can be useful to record log costs early when their content have static size.
source§fn record_log_costs(&mut self, logs: &[&Log]) -> Result<(), PrecompileFailure>
fn record_log_costs(&mut self, logs: &[&Log]) -> Result<(), PrecompileFailure>
Record cost of logs.
source§fn check_function_modifier(
&self,
modifier: FunctionModifier
) -> Result<(), Revert>
fn check_function_modifier( &self, modifier: FunctionModifier ) -> Result<(), Revert>
Check that a function call is compatible with the context it is called into.
source§fn read_u32_selector(&self) -> Result<u32, Revert>
fn read_u32_selector(&self) -> Result<u32, Revert>
Read the selector from the input data as u32.
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T
. Read more§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T
.