Skip to content

Commit 7303c0c

Browse files
committed
msgpack: save structs as maps, not vectors
1 parent db867f3 commit 7303c0c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/std/src/msgpack.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn to_msgpack_vec<T>(data: &T) -> StdResult<Vec<u8>>
2121
where
2222
T: Serialize + ?Sized,
2323
{
24-
rmp_serde::to_vec(data).map_err(|e| StdError::serialize_err(type_name::<T>(), e))
24+
rmp_serde::to_vec_named(data).map_err(|e| StdError::serialize_err(type_name::<T>(), e))
2525
}
2626

2727
/// Serializes the given data structure as MessagePack bytes.
@@ -54,7 +54,7 @@ mod tests {
5454

5555
fn refund_test_vector() -> (SomeMsg, &'static [u8]) {
5656
let msg = SomeMsg::Refund {};
57-
let serialized = &[129, 166, 114, 101, 102, 117, 110, 100, 144];
57+
let serialized = &[129, 166, 114, 101, 102, 117, 110, 100, 128];
5858
(msg, serialized)
5959
}
6060

@@ -66,8 +66,9 @@ mod tests {
6666
karma: -17,
6767
};
6868
let serialized = &[
69-
129, 171, 114, 101, 108, 101, 97, 115, 101, 95, 97, 108, 108, 148, 163, 102, 111, 111,
70-
42, 207, 255, 255, 255, 255, 255, 255, 255, 255, 239,
69+
129, 171, 114, 101, 108, 101, 97, 115, 101, 95, 97, 108, 108, 132, 165, 105, 109, 97,
70+
103, 101, 163, 102, 111, 111, 166, 97, 109, 111, 117, 110, 116, 42, 164, 116, 105, 109,
71+
101, 207, 255, 255, 255, 255, 255, 255, 255, 255, 165, 107, 97, 114, 109, 97, 239,
7172
];
7273
(msg, serialized)
7374
}
@@ -125,8 +126,7 @@ mod tests {
125126
}
126127

127128
#[test]
128-
#[should_panic(expected = "invalid type: string \\\"foo\\\", expected u32")]
129-
fn deserialize_different_field_order_unsupported() {
129+
fn deserialize_modified_field_order() {
130130
#[derive(Serialize, Deserialize, Debug, PartialEq)]
131131
struct TestV1 {
132132
a: String,

0 commit comments

Comments
 (0)