Skip to content

Commit

Permalink
Optimize size guard test case
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Apr 23, 2024
1 parent d59c7d1 commit 2d66247
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/core/src/transport/symmetric_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,21 @@ mod test {
payload: SymmetricMessagePayload::NoOp,
};
let size = bincode::serialized_size(&msg).unwrap();
assert!(size <= MAX_DATA_SIZE as u64);
assert_eq!(size, MAX_DATA_SIZE as u64);
}

#[test]
fn short_message_overhead() {
fn max_short_message() {
let overhead = SymmetricMessage::short_message_overhead();
println!("overhead: {}", overhead);
}

#[test]
fn noop_message_overhead() {
let overhead = SymmetricMessage::noop_message_overhead();
println!("overhead: {}", overhead);
let msg = SymmetricMessage {
packet_id: u32::MAX,
confirm_receipt: vec![],
payload: SymmetricMessagePayload::ShortMessage {
payload: vec![0; MAX_DATA_SIZE - overhead],
},
};
let size = bincode::serialized_size(&msg).unwrap();
assert_eq!(size, MAX_DATA_SIZE as u64);
}
}

0 comments on commit 2d66247

Please sign in to comment.