From bad974c8d8e5eccc633b56f2da525d5645b4acd3 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Fri, 26 Apr 2024 22:29:14 +0200 Subject: [PATCH] test proto::Any json ser-der --- .../testapp/ibc/clients/mock/client_state.rs | 19 +++++++++++++++++++ ibc-testkit/src/testapp/ibc/clients/mod.rs | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) 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 05ff95440..c89c29778 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs @@ -492,3 +492,22 @@ impl From for MockClientState { Self::new(cs.header) } } + +#[cfg(test)] +mod test { + use ibc::primitives::proto::Any; + + use super::{MockClientState, MockHeader}; + + #[cfg(feature = "serde")] + #[test] + fn test_any_client_state_to_json() { + let client_state = MockClientState::new(MockHeader::default()); + let expected = r#"{"typeUrl":"/ibc.mock.ClientState","value":"CgQKAhABEIDIr6Al"}"#; + let json = serde_json::to_string(&Any::from(client_state)).unwrap(); + assert_eq!(json, expected); + + let proto_any = serde_json::from_str::(expected).unwrap(); + assert_eq!(proto_any, Any::from(client_state)); + } +} diff --git a/ibc-testkit/src/testapp/ibc/clients/mod.rs b/ibc-testkit/src/testapp/ibc/clients/mod.rs index 6eec7efa2..1f7e364c6 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mod.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mod.rs @@ -126,22 +126,3 @@ impl TryFrom for MockConsensusState { } } } - -#[cfg(test)] -mod test { - use ibc::primitives::proto::Any; - - use super::mock::header::MockHeader; - use crate::testapp::ibc::clients::mock::client_state::MockClientState; - - #[test] - fn test_any_client_state_to_json() { - let client_state = MockClientState::new(MockHeader::default()); - let expected = r#"{"typeUrl":"/ibc.mock.ClientState","value":"CgQKAhABEIDIr6Al"}"#; - let json = serde_json::to_string(&Any::from(client_state)).unwrap(); - assert_eq!(json, expected); - - let proto_any = serde_json::from_str::(expected).unwrap(); - assert_eq!(proto_any, Any::from(client_state)); - } -}