Add unit test for compute_max_recv_size

This commit is contained in:
Matéo Duparc 2021-07-25 15:41:09 +02:00
parent e2f38468c7
commit eacd948236
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
1 changed files with 11 additions and 2 deletions

View File

@ -664,7 +664,7 @@ fn hex_encode(buff: &[u8]) -> String {
#[cfg(test)]
mod tests {
use super::{pad, unpad, MESSAGE_LEN_LEN};
use super::{pad, unpad, compute_max_recv_size, MESSAGE_LEN_LEN};
#[test]
fn padding() {
@ -680,4 +680,13 @@ mod tests {
let large_msg = "a".repeat(5000);
assert_eq!(pad(large_msg.as_bytes(), true).len(), 8000);
}
}
#[test]
fn compute_max_size() {
assert_eq!(compute_max_recv_size(5, false), 1016);
assert_eq!(compute_max_recv_size(996, false), 1016);
assert_eq!(compute_max_recv_size(997, false), 2016);
assert_eq!(compute_max_recv_size(16383996, false), 16384016);
assert_eq!(compute_max_recv_size(16383997, false), 32768016)
}
}