Skip to content

Commit

Permalink
Add MessageId for I/O message SMO (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlopes11 authored Jun 23, 2022
1 parent 528d515 commit 062edb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ key!(ContractId, 32);
key!(Bytes4, 4);
key!(Bytes8, 8);
key!(Bytes32, 32);
key!(MessageId, 32);
key!(Salt, 32);

key_with_big_array!(Bytes64, 64);
Expand Down
13 changes: 13 additions & 0 deletions tests/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn from_slice_unchecked_safety() {
check_consistency!(Bytes8, rng, bytes);
check_consistency!(Bytes32, rng, bytes);
check_consistency!(Bytes64, rng, bytes);
check_consistency!(MessageId, rng, bytes);
check_consistency!(Salt, rng, bytes);
}
}
Expand Down Expand Up @@ -124,6 +125,7 @@ fn hex_encoding() {
encode_decode::<Bytes8>(rng.gen());
encode_decode::<Bytes32>(rng.gen());
encode_decode::<Bytes64>(rng.gen());
encode_decode::<MessageId>(rng.gen());
encode_decode::<Salt>(rng.gen());
}

Expand All @@ -137,6 +139,7 @@ fn test_key_serde() {
let bytes4: Bytes4 = rng.gen();
let bytes8: Bytes8 = rng.gen();
let bytes32: Bytes32 = rng.gen();
let message_id: MessageId = rng.gen();
let salt: Salt = rng.gen();
let bytes64: Bytes64 = rng.gen();

Expand Down Expand Up @@ -166,6 +169,11 @@ fn test_key_serde() {
bincode::deserialize(&bytes32_t).expect("Failed to deserialize Bytes32");
assert_eq!(bytes32, bytes32_t);

let message_id_t = bincode::serialize(&message_id).expect("Failed to serialize MessageId");
let message_id_t: MessageId =
bincode::deserialize(&message_id_t).expect("Failed to deserialize MessageId");
assert_eq!(message_id, message_id_t);

let salt_t = bincode::serialize(&salt).expect("Failed to serialize Salt");
let salt_t: Salt = bincode::deserialize(&salt_t).expect("Failed to deserialize Salt");
assert_eq!(salt, salt_t);
Expand Down Expand Up @@ -211,6 +219,11 @@ fn test_key_types_hex_serialization() {
serde_json::to_string(&bytes32).expect("serde_json::to_string failed on Bytes32");
assert_eq!(format!("\"{}\"", bytes32), bytes32_to_string);

let message_id: MessageId = rng.gen();
let message_id_to_string =
serde_json::to_string(&message_id).expect("serde_json::to_string failed on MessageId");
assert_eq!(format!("\"{}\"", message_id), message_id_to_string);

let salt: Salt = rng.gen();
let salt_to_string =
serde_json::to_string(&salt).expect("serde_json::to_string failed on Salt");
Expand Down

0 comments on commit 062edb8

Please sign in to comment.