Skip to content

Commit

Permalink
refactor: consistent error messages (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
antouhou authored Oct 15, 2021
1 parent ce35f20 commit cbda7a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ impl Error {
pub fn not_enough_helper_nodes() -> Self {
Self::new(
ErrorKind::NotEnoughHelperNodes,
String::from("Not enough hashes to reconstruct the root"),
String::from("not enough hashes to reconstruct the root"),
)
}

pub fn wrong_proof_size(proof_len: usize, hash_size: usize) -> Self {
Self::new(
ErrorKind::SerializedProofSizeIsIncorrect,
format!(
"Proof of size {} bytes can not be divided into chunks of {} bytes",
"proof of size {} bytes can not be divided into chunks of {} bytes",
proof_len, hash_size,
),
)
Expand All @@ -39,14 +39,14 @@ impl Error {
pub fn vec_to_hash_conversion_error() -> Self {
Self::new(
ErrorKind::HashConversionError,
"Couldn't convert proof hash data into Hasher::Hash".to_string(),
"couldn't convert proof hash data into Hasher::Hash".to_string(),
)
}

pub fn not_enough_hashes_to_calculate_root() -> Self {
Self::new(
ErrorKind::NotEnoughHashesToCalculateRoot,
"Proof doesn't contain enough data to extract the root".to_string(),
"proof doesn't contain enough data to extract the root".to_string(),
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/merkle_proof_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub mod from_bytes {

assert_eq!(
err.message(),
"Proof of size 84 bytes can not be divided into chunks of 32 bytes"
"proof of size 84 bytes can not be divided into chunks of 32 bytes"
);
}
}

0 comments on commit cbda7a0

Please sign in to comment.