Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow all-zero messages #207

Merged
merged 1 commit into from Aug 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/lib.rs
Expand Up @@ -454,10 +454,6 @@ impl Message {
/// Converts a `MESSAGE_SIZE`-byte slice to a message object
#[inline]
pub fn from_slice(data: &[u8]) -> Result<Message, Error> {
if data == [0; constants::MESSAGE_SIZE] {
return Err(Error::InvalidMessage);
}

match data.len() {
constants::MESSAGE_SIZE => {
let mut ret = [0; constants::MESSAGE_SIZE];
Expand Down Expand Up @@ -1007,10 +1003,7 @@ mod tests {
Err(InvalidMessage));
assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE + 1]),
Err(InvalidMessage));
assert_eq!(
Message::from_slice(&[0; constants::MESSAGE_SIZE]),
Err(InvalidMessage)
);
assert!(Message::from_slice(&[0; constants::MESSAGE_SIZE]).is_ok());
assert!(Message::from_slice(&[1; constants::MESSAGE_SIZE]).is_ok());
}

Expand Down