Struct ethcontract_mock::Contract [−][src]
pub struct Contract { /* fields omitted */ }Expand description
A mocked contract deployed by the mock node.
This struct allows setting up expectations on which contract methods will be called, with what arguments, in what order, etc.
Implementations
Creates a Web3 object that can be used to interact with
the mocked chain on which this contract is deployed.
Creates a Transport object that can be used to interact with
the mocked chain.
Creates a contract Instance that can be used to interact with
this contract.
Consumes this object and transforms it into a contract Instance
that can be used to interact with this contract.
Adds a new expectation for contract method. See Expectation.
Generic parameters are used to specify which rust types should be used to encode and decode method’s arguments and return value. If you’re using generated contracts, they will be inferred automatically. If not, you may have to specify them manually.
Notes
Expectations generated by this method will allow both view calls
and transactions. This is usually undesired, so prefer using
expect_call and expect_transaction instead.
pub fn expect_call<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static>(
&self,
signature: impl Into<Signature<P, R>>
) -> Expectation<P, R>
pub fn expect_call<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static>(
&self,
signature: impl Into<Signature<P, R>>
) -> Expectation<P, R>
Adds a new expectation for contract method that only matches view calls.
This is an equivalent of expect followed by allow_transactions(false).
pub fn expect_transaction<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static>(
&self,
signature: impl Into<Signature<P, R>>
) -> Expectation<P, R>
pub fn expect_transaction<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static>(
&self,
signature: impl Into<Signature<P, R>>
) -> Expectation<P, R>
Adds a new expectation for contract method that only matches transactions.
This is an equivalent of expect followed by allow_calls(false).
Verifies that all expectations on this contract have been met, then clears all expectations.
Sometimes its useful to validate all expectations mid-test, throw them away, and add new ones. That’s what checkpoints do. See mockall documentation for more info.
Note that all expectations returned from expect method
become invalid after checkpoint. Modifying them will result in panic.
Auto Trait Implementations
impl RefUnwindSafe for Contract
impl UnwindSafe for Contract
Blanket Implementations
fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745 Read more
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = T
Should always be Self