ibc-testkit 0.57.0

Maintained by `ibc-rs`, serves as a versatile library that provides essential abstractions and implementations, fulfilling a dual role of enabling rigorous integration testing for the `ibc-rs` implementation while also aiding host chains in addressing a broad spectrum of testing scenarios during their integrations with `ibc-rs`.
Documentation
use ibc::clients::tendermint::types::ConsensusState as TmConsensusState;
use ibc::core::client::types::proto::v1::MsgCreateClient as RawMsgCreateClient;
use ibc::primitives::proto::Any;

use crate::fixtures::clients::tendermint::{
    dummy_tm_client_state_from_header, dummy_valid_tendermint_header,
};
use crate::fixtures::core::signer::dummy_bech32_account;

/// Returns a dummy `RawMsgCreateClient`, for testing purposes only!
pub fn dummy_raw_msg_create_client() -> RawMsgCreateClient {
    let tm_header = dummy_valid_tendermint_header();

    let tm_client_state = dummy_tm_client_state_from_header(tm_header.clone());

    RawMsgCreateClient {
        client_state: Some(Any::from(tm_client_state)),
        consensus_state: Some(Any::from(TmConsensusState::from(tm_header))),
        signer: dummy_bech32_account(),
    }
}

#[cfg(test)]
mod tests {
    use ibc::core::client::types::msgs::MsgCreateClient;

    use super::*;

    #[test]
    fn msg_create_client_serialization() {
        let raw = dummy_raw_msg_create_client();
        let msg = MsgCreateClient::try_from(raw.clone()).unwrap();
        let raw_back = RawMsgCreateClient::from(msg.clone());
        let msg_back = MsgCreateClient::try_from(raw_back.clone()).unwrap();
        assert_eq!(msg, msg_back);
        assert_eq!(raw, raw_back);
    }
}