Skip to content

Commit

Permalink
Add test for CommitHash encoding and decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
2-NOW committed Oct 15, 2023
1 parent df98735 commit 8e094b9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,15 @@ pub struct FinalizationInfo {

#[cfg(test)]
mod tests {
use super::CommitHash;
use serde_json::{from_str, to_string};

#[test]
fn en_decode_commit_hash() {
// TODO: test a successful encode/decode of CommitHash
let commit_hash = CommitHash { hash: [1; 20] };
let serialized = to_string(&commit_hash).unwrap();
assert_eq!(serialized, "\"0101010101010101010101010101010101010101\"");
let deserialized: CommitHash = from_str(&serialized).unwrap();
assert_eq!(deserialized, commit_hash);
}
}

0 comments on commit 8e094b9

Please sign in to comment.