From 304348b63dc3f0dec0d43de0f693393c17343890 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 9 Nov 2023 16:00:07 +0100 Subject: [PATCH] Add test for CosmosMsg from AnyMsg --- packages/std/src/results/cosmos_msg.rs | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 45d18b57e2..9c60c25bbf 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -427,6 +427,33 @@ mod tests { } } + #[test] + fn from_any_msg_works() { + // should work with AnyMsg + let any = AnyMsg { + type_url: "/cosmos.foo.v1beta.MsgBar".to_string(), + value: Binary::from_base64("5yu/rQ+HrMcxH1zdga7P5hpGMLE=").unwrap(), + }; + let msg: CosmosMsg = any.clone().into(); + assert!(matches!(msg, CosmosMsg::Any(a) if a == any)); + + // should work with Into + struct IntoAny; + impl From for AnyMsg { + fn from(_: IntoAny) -> Self { + AnyMsg { + type_url: "/cosmos.foo.v1beta.MsgBar".to_string(), + value: Binary::from_base64("5yu/rQ+HrMcxH1zdga7P5hpGMLE=").unwrap(), + } + } + } + let msg: CosmosMsg = IntoAny.into(); + assert!(matches!( + msg, + CosmosMsg::Any(a) if a == any + )); + } + #[test] fn wasm_msg_serializes_to_correct_json() { // Instantiate with admin