diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2023-01-02 12:24:59 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2023-01-02 15:20:14 +0100 |
commit | b96c889014ff4c7ed50058648c63710126805908 (patch) | |
tree | bc76753d366b9d86ecc8c94d6e2f45c79ac2d8e7 | |
parent | be6f9a1e8fc649021dfcdc896645cc8af8d22d22 (diff) |
Use MPacketKind instead of hand-writing bytes
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | mqtt-tester/Cargo.toml | 1 | ||||
-rw-r--r-- | mqtt-tester/src/client_report.rs | 15 |
3 files changed, 13 insertions, 4 deletions
@@ -600,6 +600,7 @@ dependencies = [ "clap 3.2.23", "futures", "miette", + "mqtt-format", "textwrap 0.15.2", "tokio", ] diff --git a/mqtt-tester/Cargo.toml b/mqtt-tester/Cargo.toml index dd6ec06..b5c5a25 100644 --- a/mqtt-tester/Cargo.toml +++ b/mqtt-tester/Cargo.toml @@ -11,5 +11,6 @@ bytes = "1.1.0" clap = { version = "3.2.8", features = ["derive"] } futures = "0.3" miette = { version = "5.1.1", features = ["fancy"] } +mqtt-format = { path = "../mqtt-format", version = "0.2.0" } textwrap = "0.15.0" tokio = { version = "1.20", features = ["macros", "process", "rt", "rt-multi-thread", "io-util", "time"] } diff --git a/mqtt-tester/src/client_report.rs b/mqtt-tester/src/client_report.rs index 9d85caf..c0e277c 100644 --- a/mqtt-tester/src/client_report.rs +++ b/mqtt-tester/src/client_report.rs @@ -9,6 +9,8 @@ use std::process::Stdio; use std::time::Duration; use futures::FutureExt; +use mqtt_format::v3::header::MPacketKind; +use mqtt_format::v3::qos::MQualityOfService; use tokio::process::Command; use crate::report::{Report, ReportResult}; @@ -49,13 +51,18 @@ async fn check_invalid_utf8_is_rejected(client_exe_path: &Path) -> miette::Resul .map(crate::command::Command::new)? .wait_for_write([ crate::command::ClientCommand::Send(vec![ - 0b0010_0000, // CONNACK + MPacketKind::Connack.to_byte(), 0b0000_0010, // Remaining length 0b0000_0000, // No session present 0b0000_0000, // Connection accepted ]), crate::command::ClientCommand::Send(vec![ - 0b0011_0000, // PUBLISH packet, DUP = 0, QoS = 0, Retain = 0 + (MPacketKind::Publish { + dup: false, + qos: MQualityOfService::AtMostOnce, + retain: false, + }) + .to_byte(), 0b0000_0111, // Length // Now the variable header 0b0000_0000, @@ -96,13 +103,13 @@ async fn check_receiving_server_packet(client_exe_path: &Path) -> miette::Result .map(crate::command::Command::new)? .wait_for_write([ crate::command::ClientCommand::Send(vec![ - 0b0010_0000, // CONNACK + MPacketKind::Connack.to_byte(), 0b0000_0010, // Remaining length 0b0000_0000, // No session present 0b0000_0000, // Connection accepted ]), crate::command::ClientCommand::Send(vec![ - 0b1000_0010, // SUBSCRIBE packet + MPacketKind::Subscribe.to_byte(), 0b0000_1000, // Length // Now the variable header 0b0000_0000, // Packet ID |