Skip to content

Commit

Permalink
fountain: test invalid padding error case
Browse files Browse the repository at this point in the history
  • Loading branch information
dspicher committed Feb 6, 2025
1 parent 5cf0135 commit 474a167
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/fountain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,4 +1129,17 @@ mod tests {
assert_eq!(super::Error::ExpectedItem.to_string(), "expected item");
assert_eq!(super::Error::InvalidPadding.to_string(), "invalid padding");
}

#[test]
fn test_invalid_padding() {
let mut encoder = Encoder::new(b"Hello world", 20).unwrap();
let mut part = encoder.next_part();
part.message_length -= 1;
let mut decoder = Decoder::default();
decoder.receive(part).unwrap();
assert_eq!(
decoder.message().unwrap_err().to_string(),
"invalid padding"
);
}
}

0 comments on commit 474a167

Please sign in to comment.