Skip to content

Commit

Permalink
Add test for CosmosMsg from AnyMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 16, 2023
1 parent 728bb1f commit 304348b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/std/src/results/cosmos_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnyMsg>
struct IntoAny;
impl From<IntoAny> 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
Expand Down

0 comments on commit 304348b

Please sign in to comment.