Trait evm_adapters::Evm[][src]

pub trait Evm<State> {
    type ReturnReason: Debug + PartialEq;
Show 22 methods fn revert() -> Self::ReturnReason;
fn expected_revert(&self) -> Option<&[u8]>;
fn is_success(reason: &Self::ReturnReason) -> bool;
fn is_fail(reason: &Self::ReturnReason) -> bool;
fn initialize_contracts<I: IntoIterator<Item = (Address, Bytes)>>(
        &mut self,
        contracts: I
    );
fn state(&self) -> &State;
fn code(&self, address: Address) -> Vec<u8>;
fn set_balance(&mut self, address: Address, amount: U256);
fn reset(&mut self, state: State);
fn set_tracing_enabled(&mut self, enabled: bool) -> bool;
fn tracing_enabled(&self) -> bool;
fn debug_calls(&self) -> Vec<DebugArena>;
fn all_logs(&self) -> Vec<String>;
fn call_raw(
        &mut self,
        from: Address,
        to: Address,
        calldata: Bytes,
        value: U256,
        is_static: bool
    ) -> Result<(Bytes, Self::ReturnReason, u64, Vec<String>)>;
fn deploy(
        &mut self,
        from: Address,
        calldata: Bytes,
        value: U256
    ) -> Result<(Address, Self::ReturnReason, u64, Vec<String>)>; fn call<D: Detokenize, T: Tokenize, F: IntoFunction>(
        &mut self,
        from: Address,
        to: Address,
        func: F,
        args: T,
        value: U256
    ) -> Result<(D, Self::ReturnReason, u64, Vec<String>), EvmError> { ... }
fn traces(&self) -> Vec<CallTraceArena> { ... }
fn reset_traces(&mut self) { ... }
fn call_unchecked<T: Tokenize>(
        &mut self,
        from: Address,
        to: Address,
        func: &Function,
        args: T,
        value: U256
    ) -> Result<(Bytes, Self::ReturnReason, u64, Vec<String>)> { ... }
fn setup(
        &mut self,
        address: Address
    ) -> Result<(Self::ReturnReason, Vec<String>)> { ... }
fn failed(&mut self, address: Address) -> Result<bool> { ... }
fn check_success(
        &mut self,
        address: Address,
        reason: &Self::ReturnReason,
        should_fail: bool
    ) -> bool { ... }
}
Expand description

Low-level abstraction layer for interfacing with various EVMs. Once instantiated, one only needs to specify the transaction parameters

Associated Types

The returned reason type from an EVM (Success / Revert/ Stopped etc.)

Required methods

Gets the revert reason type

Whether a return reason should be considered successful

Whether a return reason should be considered failing

Sets the provided contract bytecode at the corresponding addresses

Gets a reference to the current state of the EVM

Sets the balance at the specified address

Resets the EVM’s state to the provided value

Turns on/off tracing, returning the previously set value

Returns whether tracing is enabled

Grabs debug steps

Gets all logs from the execution, regardless of reverts

Deploys the provided contract bytecode and returns the address

Provided methods

Performs a call_unchecked, checks if execution reverted, and proceeds to return the decoded response to the user.

Executes the specified EVM call against the state

Runs the setUp() function call to instantiate the contract’s state

Runs the failed() function call to inspect the test contract’s state and see whether the failed state var is set. This is to allow compatibility with dapptools-style DSTest smart contracts to preserve emiting of logs

Given a smart contract address, the result type and whether it’s expected to fail, it returns the test’s success status

Implementors