Skip to content

Commit 9250ae4

Browse files
committed
Allow all-zero messages
1 parent 9aa768d commit 9250ae4

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/lib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,6 @@ impl Message {
454454
/// Converts a `MESSAGE_SIZE`-byte slice to a message object
455455
#[inline]
456456
pub fn from_slice(data: &[u8]) -> Result<Message, Error> {
457-
if data == [0; constants::MESSAGE_SIZE] {
458-
return Err(Error::InvalidMessage);
459-
}
460-
461457
match data.len() {
462458
constants::MESSAGE_SIZE => {
463459
let mut ret = [0; constants::MESSAGE_SIZE];
@@ -1007,10 +1003,7 @@ mod tests {
10071003
Err(InvalidMessage));
10081004
assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE + 1]),
10091005
Err(InvalidMessage));
1010-
assert_eq!(
1011-
Message::from_slice(&[0; constants::MESSAGE_SIZE]),
1012-
Err(InvalidMessage)
1013-
);
1006+
assert!(Message::from_slice(&[0; constants::MESSAGE_SIZE]).is_ok());
10141007
assert!(Message::from_slice(&[1; constants::MESSAGE_SIZE]).is_ok());
10151008
}
10161009

0 commit comments

Comments
 (0)