Struct StoreGenericTestContext

Source
pub struct StoreGenericTestContext<S, H>{
    pub multi_store: S,
    pub host: H,
    pub ibc_store: MockIbcStore<S>,
    pub ibc_router: MockRouter,
}
Expand description

A context implementing the dependencies necessary for testing any IBC module.

Fields§

§multi_store: S

The multi store of the context. This is where the IBC store root is stored at IBC commitment prefix.

§host: H

The type of host chain underlying this mock context.

§ibc_store: MockIbcStore<S>

An object that stores all IBC related data.

§ibc_router: MockRouter

A router that can route messages to the appropriate IBC application.

Implementations§

Source§

impl<S, H> StoreGenericTestContext<S, H>

Implementation of internal interface for use in testing. The methods in this interface should not be accessible to any ICS handler.

Source

pub fn ibc_store(&self) -> &MockIbcStore<S>

Returns an immutable reference to the IBC store.

Source

pub fn ibc_store_mut(&mut self) -> &mut MockIbcStore<S>

Returns a mutable reference to the IBC store.

Source

pub fn ibc_router(&self) -> &MockRouter

Returns an immutable reference to the IBC router.

Source

pub fn ibc_router_mut(&mut self) -> &mut MockRouter

Returns a mutable reference to the IBC router.

Source

pub fn host_block(&self, target_height: &Height) -> Option<H::Block>

Returns the block at the given height from the host chain, if exists.

Source

pub fn query_latest_block(&self) -> Option<H::Block>

Returns the latest block from the host chain.

Source

pub fn light_client_latest_height(&self, client_id: &ClientId) -> Height

Returns the latest height of client state for the given ClientId.

Source

pub fn advance_block_up_to_height(self, target_height: Height) -> Self

Advances the host chain height to the given target height.

Source

pub fn advance_genesis_height( &mut self, genesis_time: Timestamp, params: &H::BlockParams, )

Advance the first height of the host chain by generating a genesis block.

This method is same as Self::advance_genesis_height. But it bootstraps the genesis block by height 1 and genesis_time.

The method starts and ends with Self::end_block and Self::begin_block, just like the Self::advance_block_height_with_params, so that it can advance to next height i.e. height 2 - just by calling Self::advance_block_height_with_params.

Source

pub fn begin_block(&mut self)

Begin a new block on the context.

This method commits the required metadata from the last block generation and consensus, and prepares the context for the next block. This includes the latest consensus state and the latest IBC commitment proof.

Source

pub fn end_block(&mut self)

End the current block on the context.

This method commits the state of the IBC store and the host’s multi store.

Source

pub fn commit_state_to_host( &mut self, block_time: Duration, params: &H::BlockParams, )

Commit store state to the current block of the host chain by:

  • Committing the state to the context’s multi store.
  • Generating a new block with the commitment.
  • Adding the generated block to the host’s block history.
Source

pub fn advance_block_height_with_params( &mut self, block_time: Duration, params: &H::BlockParams, )

Advances the host chain height by ending the current block, producing a new block, and beginning the next block.

Source

pub fn advance_block_height(&mut self)

Convenience method to advance the host chain height using default parameters.

Source

pub fn latest_height(&self) -> Height

Returns the latest height of the host chain.

Source

pub fn latest_timestamp(&self) -> Timestamp

Returns the latest timestamp of the host chain.

Source

pub fn timestamp_at(&self, height: Height) -> Timestamp

Returns the timestamp at the given height.

Source

pub fn with_client_state( self, client_id: &ClientId, client_state: AnyClientState, ) -> Self

Bootstraps the context with a client state and its corresponding ClientId.

Source

pub fn with_consensus_state( self, client_id: &ClientId, height: Height, consensus_state: AnyConsensusState, ) -> Self

Bootstraps the context with a consensus state and its corresponding ClientId and Height.

Source

pub fn generate_light_client( &self, consensus_heights: Vec<Height>, client_params: &H::LightClientParams, ) -> LightClientState<H>

Generates a light client for the host by generating a client state, as well as generating consensus states for each consensus height.

Source

pub fn with_light_client<RH>( self, client_id: &ClientId, light_client: LightClientState<RH>, ) -> Self
where RH: TestHost,

Bootstrap a light client with ClientState and its ConsensusState(s) to this context.

Source

pub fn with_connection( self, connection_id: ConnectionId, connection_end: ConnectionEnd, ) -> Self

Bootstraps an IBC connection to this context.

This does not bootstrap any light client.

Source

pub fn with_channel( self, port_id: PortId, chan_id: ChannelId, channel_end: ChannelEnd, ) -> Self

Bootstraps an IBC channel to this context.

This does not bootstrap any corresponding IBC connection or light client.

Source

pub fn with_send_sequence( self, port_id: PortId, chan_id: ChannelId, seq_number: Sequence, ) -> Self

Bootstraps a send sequence to this context.

This does not bootstrap any corresponding IBC channel, connection or light client.

Source

pub fn with_recv_sequence( self, port_id: PortId, chan_id: ChannelId, seq_number: Sequence, ) -> Self

Bootstraps a receive sequence to this context.

This does not bootstrap any corresponding IBC channel, connection or light client.

Source

pub fn with_ack_sequence( self, port_id: PortId, chan_id: ChannelId, seq_number: Sequence, ) -> Self

Bootstraps an ack sequence to this context.

This does not bootstrap any corresponding IBC channel, connection or light client.

Source

pub fn with_packet_commitment( self, port_id: PortId, chan_id: ChannelId, seq: Sequence, data: PacketCommitment, ) -> Self

Bootstraps a packet commitment to this context.

This does not bootstrap any corresponding IBC channel, connection or light client.

Source

pub fn validate(&mut self, msg: MsgEnvelope) -> Result<(), HandlerError>

Calls validate function on MsgEnvelope using the context’s IBC store and router.

Source

pub fn execute(&mut self, msg: MsgEnvelope) -> Result<(), HandlerError>

Calls execute function on MsgEnvelope using the context’s IBC store and router.

Source

pub fn dispatch(&mut self, msg: MsgEnvelope) -> Result<(), HandlerError>

Calls dispatch function on MsgEnvelope using the context’s IBC store and router.

Source

pub fn deliver(&mut self, msg: MsgEnvelope) -> Result<(), HandlerError>

A datagram passes from the relayer to the IBC module (on host chain). Alternative method to Ics18Context::send that does not exercise any serialization. Used in testing the Ics18 algorithms, hence this may return an Ics18Error.

Source

pub fn get_events(&self) -> Vec<IbcEvent>

Returns all the events that have been emitted by the context’s IBC store.

Source

pub fn get_logs(&self) -> Vec<String>

Returns all the logs that have been emitted by the context’s IBC store.

Trait Implementations§

Source§

impl<S, H> Debug for StoreGenericTestContext<S, H>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S, H> Default for StoreGenericTestContext<S, H>

Returns a StoreGenericTestContext with bare minimum initialization: no clients, no connections, and no channels are present, and the chain has Height(5). This should be used sparingly, mostly for testing the creation of new domain objects.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, H> Freeze for StoreGenericTestContext<S, H>
where <H as TestHost>::ClientState: Sized, S: Freeze, H: Freeze,

§

impl<S, H> !RefUnwindSafe for StoreGenericTestContext<S, H>

§

impl<S, H> !Send for StoreGenericTestContext<S, H>

§

impl<S, H> !Sync for StoreGenericTestContext<S, H>

§

impl<S, H> Unpin for StoreGenericTestContext<S, H>
where <H as TestHost>::ClientState: Sized, S: Unpin, H: Unpin,

§

impl<S, H> !UnwindSafe for StoreGenericTestContext<S, H>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T, Raw> IntoResponse<Raw> for T
where T: Into<Raw>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T, C> Convertible<C> for T
where T: TryFrom<C> + Into<C>,

Source§

impl<T> JsonSchemaMaybe for T