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
type ReturnReason: Debug + PartialEq
type ReturnReason: Debug + PartialEq
The returned reason type from an EVM (Success / Revert/ Stopped etc.)
Required methods
fn revert() -> Self::ReturnReason
fn revert() -> Self::ReturnReason
Gets the revert reason type
fn is_success(reason: &Self::ReturnReason) -> bool
fn is_success(reason: &Self::ReturnReason) -> bool
Whether a return reason should be considered successful
fn is_fail(reason: &Self::ReturnReason) -> bool
fn is_fail(reason: &Self::ReturnReason) -> bool
Whether a return reason should be considered failing
fn initialize_contracts<I: IntoIterator<Item = (Address, Bytes)>>(
&mut self,
contracts: I
)
fn initialize_contracts<I: IntoIterator<Item = (Address, Bytes)>>(
&mut self,
contracts: I
)
Sets the provided contract bytecode at the corresponding addresses
fn set_balance(&mut self, address: Address, amount: U256)
fn set_balance(&mut self, address: Address, amount: U256)
Sets the balance at the specified address
fn set_tracing_enabled(&mut self, enabled: bool) -> bool
fn set_tracing_enabled(&mut self, enabled: bool) -> bool
Turns on/off tracing, returning the previously set value
fn tracing_enabled(&self) -> bool
fn tracing_enabled(&self) -> bool
Returns whether tracing is enabled
fn debug_calls(&self) -> Vec<DebugArena>
fn debug_calls(&self) -> Vec<DebugArena>
Grabs debug steps
Provided methods
Performs a call_unchecked
, checks if execution reverted, and
proceeds to return the decoded response to the user.
fn traces(&self) -> Vec<CallTraceArena>
fn reset_traces(&mut self)
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
fn check_success(
&mut self,
address: Address,
reason: &Self::ReturnReason,
should_fail: bool
) -> bool
fn check_success(
&mut self,
address: Address,
reason: &Self::ReturnReason,
should_fail: bool
) -> bool
Given a smart contract address, the result type and whether it’s expected to fail, it returns the test’s success status