Commit d218509f authored by Michael Müller's avatar Michael Müller Committed by Hero Bird

Encode selectors as 4-byte array of hex strings (#214)

parent 48fb16f0
Pipeline #54880 canceled with stages
......@@ -808,7 +808,10 @@ fn serialize_selector<S>(s: &[u8; 4], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let hex = format!("0x{:02X}{:02X}{:02X}{:02X}", s[0], s[1], s[2], s[3]);
let hex = format!(
r#"["0x{:02X}","0x{:02X}","0x{:02X}","0x{:02X}"]"#,
s[0], s[1], s[2], s[3]
);
serializer.serialize_str(&hex)
}
......@@ -834,7 +837,7 @@ mod tests {
// then
assert_eq!(
json,
"{\"name\":1,\"selector\":\"0x075BCD15\",\"args\":[],\"docs\":[]}"
r#"{"name":1,"selector":"[\"0x07\",\"0x5B\",\"0xCD\",\"0x15\"]","args":[],"docs":[]}"#
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment