Struct ethcontract_mock::Mock[][src]

pub struct Mock { /* fields omitted */ }
Expand description

Mock ethereum node.

This struct implements a virtual ethereum node with a limited number of supported RPC calls. You can interact with it via the standard transport from web3.

The main feature of this struct is deploying mocked contracts and interacting with them. Create new mocked contract with a call to deploy function. Then use the returned struct to set up expectations on contract methods, get deployed contract’s address and Instance and make actual calls to it.

Deploying contracts with an RPC call is not supported at the moment.

Implementations

Creates a new mock chain.

Creates a Web3 object that can be used to interact with the mocked chain.

Creates a Transport object that can be used to interact with the mocked chain.

Deploys a new mocked contract and returns an object that allows configuring expectations for contract methods.

Updates gas price that is returned by RPC call eth_gasPrice.

Mock node does not simulate gas consumption, so this value does not affect anything if you don’t call eth_gasPrice.

Verifies that all expectations on all contracts 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 Contract::expect method become invalid after checkpoint. Modifying them will result in panic.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.