pub struct Mock { /* private fields */ }
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.

Deploys a new mocked contract with specified address 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
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.