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.

Returns a reference to the contract’s ABI.

Returns contract’s address.

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.

Adds a new expectation for contract method that only matches view calls.

This is an equivalent of expect followed by allow_transactions(false).

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

Blanket Implementations

Gets the TypeId of self. Read more

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

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.