pub struct MockFn<State> { /* private fields */ }
Expand description

Holds a function used for mocking invocations of contracts with invoke_contract.

Implementations

Create a mock function which has access to parameter, amount, balance, and state.

parameter and amount correspond to the values used in invoke_contract(.., parameter, .., amount). balance and state correspond to the values from the contract you are testing. They are used to simulate calls to the contract itself, which can change the balance and state of the contract.

The function should return a pair (state_modified, return_value), where state_modified should be set to true, if the function modifies the state parameter. It should modify the balance and state in way desired in the test, or in a way that the called contract is intended to behave.

See also returning_ok and returning_err for when you need simple mocks.

A helper that assumes that a V1 contract is invoked. This means that the return value will always be present in case of success.

A helper that assumes that a V0 contract is invoked. This means that the return value will never be present in case of success, and hence does not have to be provided by the caller.

Create a simple mock function that returns Ok with the same value every time, and signals the state is not changed.

Create a simple mock function that returns Err with same error every time.

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.

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.