File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,8 @@ impl From<Checksum> for Vec<u8> {
139
139
mod tests {
140
140
use super :: * ;
141
141
142
+ use crate :: to_json_string;
143
+
142
144
#[ test]
143
145
fn generate_works ( ) {
144
146
let wasm = vec ! [ 0x68 , 0x69 , 0x6a ] ;
@@ -218,4 +220,21 @@ mod tests {
218
220
let _: & [ u8 ; 32 ] = checksum. as_ref ( ) ;
219
221
let _: & [ u8 ] = checksum. as_ref ( ) ;
220
222
}
223
+
224
+ #[ test]
225
+ fn serde_works ( ) {
226
+ // echo -n "hij" | sha256sum
227
+ let checksum =
228
+ Checksum :: from_hex ( "722c8c993fd75a7627d69ed941344fe2a1423a3e75efd3e6778a142884227104" )
229
+ . unwrap ( ) ;
230
+
231
+ let serialized = to_json_string ( & checksum) . unwrap ( ) ;
232
+ assert_eq ! (
233
+ serialized,
234
+ "\" 722c8c993fd75a7627d69ed941344fe2a1423a3e75efd3e6778a142884227104\" "
235
+ ) ;
236
+
237
+ let deserialized: Checksum = serde_json:: from_str ( & serialized) . unwrap ( ) ;
238
+ assert_eq ! ( deserialized, checksum) ;
239
+ }
221
240
}
You can’t perform that action at this time.
0 commit comments