Skip to content

Commit 304348b

Browse files
committed
Add test for CosmosMsg from AnyMsg
1 parent 728bb1f commit 304348b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/std/src/results/cosmos_msg.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,33 @@ mod tests {
427427
}
428428
}
429429

430+
#[test]
431+
fn from_any_msg_works() {
432+
// should work with AnyMsg
433+
let any = AnyMsg {
434+
type_url: "/cosmos.foo.v1beta.MsgBar".to_string(),
435+
value: Binary::from_base64("5yu/rQ+HrMcxH1zdga7P5hpGMLE=").unwrap(),
436+
};
437+
let msg: CosmosMsg = any.clone().into();
438+
assert!(matches!(msg, CosmosMsg::Any(a) if a == any));
439+
440+
// should work with Into<AnyMsg>
441+
struct IntoAny;
442+
impl From<IntoAny> for AnyMsg {
443+
fn from(_: IntoAny) -> Self {
444+
AnyMsg {
445+
type_url: "/cosmos.foo.v1beta.MsgBar".to_string(),
446+
value: Binary::from_base64("5yu/rQ+HrMcxH1zdga7P5hpGMLE=").unwrap(),
447+
}
448+
}
449+
}
450+
let msg: CosmosMsg = IntoAny.into();
451+
assert!(matches!(
452+
msg,
453+
CosmosMsg::Any(a) if a == any
454+
));
455+
}
456+
430457
#[test]
431458
fn wasm_msg_serializes_to_correct_json() {
432459
// Instantiate with admin

0 commit comments

Comments
 (0)