Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Aug 31, 2023
1 parent 3cab7ad commit 8dfcf4a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/ibc/src/core/ics03_connection/msgs/conn_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,21 @@ mod tests {
msg_with_counterpary_conn_id_some_back
);
}

/// Test that borsh serialization/deserialization works well with delay periods up to u64::MAX
#[cfg(feature = "borsh")]
#[test]
fn test_borsh() {
let mut raw = get_dummy_raw_msg_conn_open_init();
raw.delay_period = u64::MAX;
let msg = MsgConnectionOpenInit::try_from(raw.clone()).unwrap();

let serialized = borsh::to_vec(&msg).unwrap();

let msg_deserialized =
<MsgConnectionOpenInit as borsh::BorshDeserialize>::try_from_slice(&serialized)
.unwrap();

assert_eq!(msg, msg_deserialized);
}
}
16 changes: 16 additions & 0 deletions crates/ibc/src/core/ics03_connection/msgs/conn_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,20 @@ mod tests {
assert_eq!(raw, raw_back);
assert_eq!(msg, msg_back);
}

/// Test that borsh serialization/deserialization works well with delay periods up to u64::MAX
#[cfg(feature = "borsh")]
#[test]
fn test_borsh() {
let mut raw = get_dummy_raw_msg_conn_open_try(10, 34);
raw.delay_period = u64::MAX;
let msg = MsgConnectionOpenTry::try_from(raw.clone()).unwrap();

let serialized = borsh::to_vec(&msg).unwrap();

let msg_deserialized =
<MsgConnectionOpenTry as borsh::BorshDeserialize>::try_from_slice(&serialized).unwrap();

assert_eq!(msg, msg_deserialized);
}
}

0 comments on commit 8dfcf4a

Please sign in to comment.