Skip to content

Commit

Permalink
digest: add bcs and json roundtrip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Feb 24, 2024
1 parent e823572 commit 3235dc8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/types/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,21 @@ mod test {
let d = s.parse::<Digest>().unwrap();
assert_eq!(digest, d);
}

#[test]
#[cfg(feature = "serde")]
fn roundtrip_bcs(digest: Digest) {
let b = bcs::to_bytes(&digest).unwrap();
let d = bcs::from_bytes(&b).unwrap();
assert_eq!(digest, d);
}

#[test]
#[cfg(feature = "serde")]
fn roundtrip_json(digest: Digest) {
let s = serde_json::to_string(&digest).unwrap();
let d = serde_json::from_str(&s).unwrap();
assert_eq!(digest, d);
}
}
}

0 comments on commit 3235dc8

Please sign in to comment.