diff --git a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs index fc5eca00a..60b306cd5 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs @@ -22,7 +22,6 @@ use crate::testapp::ibc::clients::mock::consensus_state::MockConsensusState; use crate::testapp::ibc::clients::mock::header::MockHeader; use crate::testapp::ibc::clients::mock::misbehaviour::Misbehaviour; use crate::testapp::ibc::clients::mock::proto::ClientState as RawMockClientState; -use crate::testapp::ibc::utils::{duration_gpb_to_ibc, duration_ibc_to_gbp}; pub const MOCK_CLIENT_STATE_TYPE_URL: &str = "/ibc.mock.ClientState"; pub const MOCK_CLIENT_TYPE: &str = "9999-mock"; @@ -38,8 +37,7 @@ pub fn client_type() -> ClientType { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct MockClientState { pub header: MockHeader, - pub max_clock_drift: Option, - pub trusting_period: Option, + pub trusting_period: Duration, pub frozen: bool, } @@ -47,8 +45,7 @@ impl MockClientState { pub fn new(header: MockHeader) -> Self { Self { header, - max_clock_drift: None, - trusting_period: None, + trusting_period: Duration::from_nanos(0), frozen: false, } } @@ -61,6 +58,13 @@ impl MockClientState { None } + pub fn with_trusting_period(self, trusting_period: Duration) -> Self { + Self { + trusting_period, + ..self + } + } + pub fn with_frozen_height(self, _frozen_height: Height) -> Self { Self { frozen: true, @@ -90,8 +94,7 @@ impl TryFrom for MockClientState { description: "header is not present".into(), })? .try_into()?, - max_clock_drift: raw.max_clock_drift.map(duration_gpb_to_ibc), - trusting_period: raw.trusting_period.map(duration_gpb_to_ibc), + trusting_period: Duration::from_nanos(raw.trusting_period), frozen: raw.frozen, }) } @@ -101,8 +104,7 @@ impl From for RawMockClientState { fn from(value: MockClientState) -> Self { RawMockClientState { header: Some(value.header.into()), - max_clock_drift: value.max_clock_drift.map(duration_ibc_to_gbp), - trusting_period: value.trusting_period.map(duration_ibc_to_gbp), + trusting_period: value.trusting_period.as_nanos() as _, frozen: value.frozen, } } diff --git a/ibc-testkit/src/testapp/ibc/clients/mock/consensus_state.rs b/ibc-testkit/src/testapp/ibc/clients/mock/consensus_state.rs index ca6f33e09..43db3edc4 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/consensus_state.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/consensus_state.rs @@ -48,7 +48,6 @@ impl From for RawMockConsensusState { fn from(value: MockConsensusState) -> Self { RawMockConsensusState { header: Some(value.header.into()), - bytes: value.root.into_vec(), } } } diff --git a/ibc-testkit/src/testapp/ibc/clients/mock/header.rs b/ibc-testkit/src/testapp/ibc/clients/mock/header.rs index ac23f5ef7..ff6da161e 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/header.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/header.rs @@ -7,7 +7,6 @@ use ibc::core::primitives::Timestamp; use ibc::primitives::proto::{Any, Protobuf}; use crate::testapp::ibc::clients::mock::proto::Header as RawMockHeader; -use crate::testapp::ibc::utils::{timestamp_gpb_to_ibc, timestamp_ibc_to_gpb}; pub const MOCK_HEADER_TYPE_URL: &str = "/ibc.mock.Header"; @@ -50,12 +49,11 @@ impl TryFrom for MockHeader { description: "missing height".into(), })? .try_into()?, - timestamp: raw - .timestamp - .map(timestamp_gpb_to_ibc) - .ok_or(ClientError::Other { - description: "missing timestamp".into(), - })?, + timestamp: Timestamp::from_nanoseconds(raw.timestamp).map_err(|err| { + ClientError::Other { + description: err.to_string(), + } + })?, }) } } @@ -64,7 +62,7 @@ impl From for RawMockHeader { fn from(value: MockHeader) -> Self { RawMockHeader { height: Some(value.height.into()), - timestamp: Some(timestamp_ibc_to_gpb(value.timestamp)), + timestamp: value.timestamp.nanoseconds(), } } }