diff --git a/.changelog/unreleased/improvements/186-extend-ibc-mock-fields.md b/.changelog/unreleased/improvements/186-extend-ibc-mock-fields.md new file mode 100644 index 00000000..0f390b34 --- /dev/null +++ b/.changelog/unreleased/improvements/186-extend-ibc-mock-fields.md @@ -0,0 +1,3 @@ +- Extend `ibc::mock::ClientState` with `trusting_period` and `frozen` data + fields to cover a wider range of client state testing scenarios + ([\#186](https://github.com/cosmos/ibc-proto-rs/issues/186)). diff --git a/definitions/mock/ibc.mock.proto b/definitions/mock/ibc.mock.proto index d8a2fe59..3b57cb2b 100644 --- a/definitions/mock/ibc.mock.proto +++ b/definitions/mock/ibc.mock.proto @@ -5,11 +5,13 @@ import "ibc/core/client/v1/client.proto"; message Header { ibc.core.client.v1.Height height = 1; - uint64 timestamp = 2; + uint64 timestamp = 2; } message ClientState { Header header = 1; + uint64 trusting_period = 2; + bool frozen = 3; } message ConsensusState { diff --git a/src/prost/ibc.mock.rs b/src/prost/ibc.mock.rs index d47fadf7..e608e01d 100644 --- a/src/prost/ibc.mock.rs +++ b/src/prost/ibc.mock.rs @@ -18,6 +18,10 @@ impl ::prost::Name for Header { pub struct ClientState { #[prost(message, optional, tag = "1")] pub header: ::core::option::Option
, + #[prost(uint64, tag = "2")] + pub trusting_period: u64, + #[prost(bool, tag = "3")] + pub frozen: bool, } impl ::prost::Name for ClientState { const NAME: &'static str = "ClientState"; diff --git a/src/prost/ibc.mock.serde.rs b/src/prost/ibc.mock.serde.rs index 0e279efd..67700bbd 100644 --- a/src/prost/ibc.mock.serde.rs +++ b/src/prost/ibc.mock.serde.rs @@ -9,10 +9,23 @@ impl serde::Serialize for ClientState { if true { len += 1; } + if true { + len += 1; + } + if true { + len += 1; + } let mut struct_ser = serializer.serialize_struct("ibc.mock.ClientState", len)?; if let Some(v) = self.header.as_ref() { struct_ser.serialize_field("header", v)?; } + if true { + #[allow(clippy::needless_borrow)] + struct_ser.serialize_field("trustingPeriod", ::alloc::string::ToString::to_string(&self.trusting_period).as_str())?; + } + if true { + struct_ser.serialize_field("frozen", &self.frozen)?; + } struct_ser.end() } } @@ -24,11 +37,16 @@ impl<'de> serde::Deserialize<'de> for ClientState { { const FIELDS: &[&str] = &[ "header", + "trusting_period", + "trustingPeriod", + "frozen", ]; #[allow(clippy::enum_variant_names)] enum GeneratedField { Header, + TrustingPeriod, + Frozen, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> core::result::Result @@ -51,6 +69,8 @@ impl<'de> serde::Deserialize<'de> for ClientState { { match value { "header" => Ok(GeneratedField::Header), + "trustingPeriod" | "trusting_period" => Ok(GeneratedField::TrustingPeriod), + "frozen" => Ok(GeneratedField::Frozen), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } @@ -71,6 +91,8 @@ impl<'de> serde::Deserialize<'de> for ClientState { V: serde::de::MapAccess<'de>, { let mut header__ = None; + let mut trusting_period__ = None; + let mut frozen__ = None; while let Some(k) = map_.next_key()? { match k { GeneratedField::Header => { @@ -79,10 +101,26 @@ impl<'de> serde::Deserialize<'de> for ClientState { } header__ = map_.next_value()?; } + GeneratedField::TrustingPeriod => { + if trusting_period__.is_some() { + return Err(serde::de::Error::duplicate_field("trustingPeriod")); + } + trusting_period__ = + Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0) + ; + } + GeneratedField::Frozen => { + if frozen__.is_some() { + return Err(serde::de::Error::duplicate_field("frozen")); + } + frozen__ = Some(map_.next_value()?); + } } } Ok(ClientState { header: header__, + trusting_period: trusting_period__.unwrap_or_default(), + frozen: frozen__.unwrap_or_default(), }) } } diff --git a/src/prost/proto_descriptor.bin b/src/prost/proto_descriptor.bin index ae805c55..e1e93ac3 100644 Binary files a/src/prost/proto_descriptor.bin and b/src/prost/proto_descriptor.bin differ