Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed May 2, 2024
1 parent 0cb6ffd commit bb3e567
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mqttrust_core/src/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ where

fn backoff(&self) -> TimerDurationU32<TIMER_HZ> {
let base_time_ms: u32 = 1000;
let backoff = base_time_ms.saturating_mul(u32::pow(2, self.connect_counter as u32 - 1));
let backoff = base_time_ms.saturating_mul(u32::pow(2, self.connect_counter as u32));

Check warning on line 223 in mqttrust_core/src/eventloop.rs

View workflow job for this annotation

GitHub Actions / clippy

casting `u8` to `u32` may become silently lossy if you later change the type

warning: casting `u8` to `u32` may become silently lossy if you later change the type --> mqttrust_core/src/eventloop.rs:223:63 | 223 | let backoff = base_time_ms.saturating_mul(u32::pow(2, self.connect_counter as u32)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::from(self.connect_counter)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless = note: `-W clippy::cast-lossless` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::cast_lossless)]`

core::cmp::min(50.secs(), backoff.millis())
}
Expand Down Expand Up @@ -725,12 +725,12 @@ mod tests {
rx_buf.range.end += connack_len;
let publish_len = encode_slice(&Packet::from(publish.clone()), rx_buf.buffer()).unwrap();
rx_buf.range.end += publish_len;
assert_eq!(rx_buf.range.end, rx_buf.buffer.capacity());
assert_eq!(rx_buf.range.end, 4096);

// Decode the first Connack packet on the Handshake state.
state.connection_status = MqttConnectionStatus::Handshake;
let (n, p) = PacketDecoder::new(&mut rx_buf).decode(&mut state).unwrap();
assert_eq!(n, Some(Notification::ConnAck));
assert!(matches!(n, Some(Notification::ConnAck(_))));
assert_eq!(p, None);

let mut pkg = SerializedPacket(&mut rx_buf.buffer[rx_buf.range]);
Expand Down Expand Up @@ -776,7 +776,7 @@ mod tests {
rx_buf.range.end += connack_malformed_len;
let publish_len = encode_slice(&Packet::from(publish.clone()), rx_buf.buffer()).unwrap();
rx_buf.range.end += publish_len;
assert_eq!(rx_buf.range.end, rx_buf.buffer.capacity());
assert_eq!(rx_buf.range.end, 4096);

// When a packet is malformed, we cannot tell its length. The decoder
// discards the entire buffer.
Expand Down

0 comments on commit bb3e567

Please sign in to comment.