referrerpolicy=no-referrer-when-downgrade

Trait MockHandler

Source
pub trait MockHandler<T: Config> {
    // Provided methods
    fn mock_call(
        &self,
        _callee: H160,
        _call_data: &[u8],
        _value_transferred: U256,
    ) -> Option<ExecReturnValue> { ... }
    fn mock_caller(&self, _frames_len: usize) -> Option<OriginFor<T>> { ... }
    fn mock_origin(&self) -> Option<&Origin<T>> { ... }
    fn mock_delegated_caller(
        &self,
        _dest: H160,
        _input_data: &[u8],
    ) -> Option<DelegateInfo<T>> { ... }
}
Expand description

A trait that provides hooks for mocking EVM contract calls and callers. This is useful for testing and simulating contract interactions within foundry forge tests.

Provided Methods§

Source

fn mock_call( &self, _callee: H160, _call_data: &[u8], _value_transferred: U256, ) -> Option<ExecReturnValue>

Mock an EVM contract call.

Returns Some(ExecReturnValue) if the call is mocked, otherwise None.

Source

fn mock_caller(&self, _frames_len: usize) -> Option<OriginFor<T>>

Mock the caller of a contract.

§Parameters
  • _frames_len: The current number of frames on the call stack.

Returns Some(OriginFor<T>) if the caller is mocked, otherwise None.

Source

fn mock_origin(&self) -> Option<&Origin<T>>

Mock the origin of a contract.

Returns Some(&Origin<T>) if the caller is mocked, otherwise None.

Source

fn mock_delegated_caller( &self, _dest: H160, _input_data: &[u8], ) -> Option<DelegateInfo<T>>

Mock a delegated caller for a contract call.

Returns Some(DelegateInfo<T>) if the delegated caller is mocked, otherwise None.

Implementors§