diff options
Diffstat (limited to 'mqtt-tester/src/behaviour')
9 files changed, 39 insertions, 13 deletions
diff --git a/mqtt-tester/src/behaviour/connack_flags_are_set_as_reserved.rs b/mqtt-tester/src/behaviour/connack_flags_are_set_as_reserved.rs index b128be7..7229f94 100644 --- a/mqtt-tester/src/behaviour/connack_flags_are_set_as_reserved.rs +++ b/mqtt-tester/src/behaviour/connack_flags_are_set_as_reserved.rs @@ -4,6 +4,8 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; + use crate::{ behaviour_test::BehaviourTest, command::{Input, Output}, @@ -28,7 +30,8 @@ impl BehaviourTest for ConnackFlagsAreSetAsReserved { 0b0000_0000, // No session present 0b0000_0000, // Connection accepted ]) - .await?; + .await + .context("Sending bytes")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/first_packet_from_client_is_connect.rs b/mqtt-tester/src/behaviour/first_packet_from_client_is_connect.rs index 1315a63..5f114c2 100644 --- a/mqtt-tester/src/behaviour/first_packet_from_client_is_connect.rs +++ b/mqtt-tester/src/behaviour/first_packet_from_client_is_connect.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::packet::MPacket; use crate::{ @@ -37,7 +38,8 @@ impl BehaviourTest for FirstPacketFromClientIsConnect { std::matches!(packet, MPacket::Connect { .. }) }), ) - .await?; + .await + .context("Waiting for bytes to check")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/invalid_first_packet_is_rejected.rs b/mqtt-tester/src/behaviour/invalid_first_packet_is_rejected.rs index ea3d663..d3f1a4a 100644 --- a/mqtt-tester/src/behaviour/invalid_first_packet_is_rejected.rs +++ b/mqtt-tester/src/behaviour/invalid_first_packet_is_rejected.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::{packet::MConnect, strings::MString}; use crate::{ @@ -34,7 +35,8 @@ impl BehaviourTest for InvalidFirstPacketIsRejected { keep_alive: 0, client_id: MString { value: "client" }, }) - .await?; + .await + .context("Sending bytes")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/invalid_utf8_is_rejected.rs b/mqtt-tester/src/behaviour/invalid_utf8_is_rejected.rs index cb77b80..b937ab1 100644 --- a/mqtt-tester/src/behaviour/invalid_utf8_is_rejected.rs +++ b/mqtt-tester/src/behaviour/invalid_utf8_is_rejected.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::{connect_return::MConnectReturnCode, packet::MConnack}; use crate::{ @@ -28,7 +29,8 @@ impl BehaviourTest for InvalidUtf8IsRejected { session_present: false, connect_return_code: MConnectReturnCode::Accepted, }) - .await?; + .await + .context("Sending packet: CONNACK")?; input .send(&[ @@ -43,7 +45,8 @@ impl BehaviourTest for InvalidUtf8IsRejected { 0b0000_0001, 0x1, // Payload ]) - .await?; + .await + .context("Sending bytes")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/publish_qos_2_is_acked.rs b/mqtt-tester/src/behaviour/publish_qos_2_is_acked.rs index 1e57928..d18871c 100644 --- a/mqtt-tester/src/behaviour/publish_qos_2_is_acked.rs +++ b/mqtt-tester/src/behaviour/publish_qos_2_is_acked.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::{ connect_return::MConnectReturnCode, identifier::MPacketIdentifier, @@ -34,7 +35,8 @@ impl BehaviourTest for PublishQos2IsAcked { session_present: false, connect_return_code: MConnectReturnCode::Accepted, }) - .await?; + .await + .context("Sending packet CONNACK")?; input .send_packet(MPublish { @@ -45,7 +47,8 @@ impl BehaviourTest for PublishQos2IsAcked { id: Some(MPacketIdentifier(1)), payload: &[0x00], }) - .await?; + .await + .context("Sending packet PUBLISH")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/publish_qos_zero_with_ident_fails.rs b/mqtt-tester/src/behaviour/publish_qos_zero_with_ident_fails.rs index 5f80a66..64cbddd 100644 --- a/mqtt-tester/src/behaviour/publish_qos_zero_with_ident_fails.rs +++ b/mqtt-tester/src/behaviour/publish_qos_zero_with_ident_fails.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::{ connect_return::MConnectReturnCode, identifier::MPacketIdentifier, @@ -34,7 +35,8 @@ impl BehaviourTest for PublishQosZeroWithIdentFails { session_present: false, connect_return_code: MConnectReturnCode::Accepted, }) - .await?; + .await + .context("Sending packet CONNACK")?; input .send_packet(MPublish { @@ -45,7 +47,8 @@ impl BehaviourTest for PublishQosZeroWithIdentFails { id: Some(MPacketIdentifier(1)), payload: &[0x00], }) - .await?; + .await + .context("Sending packet PUBLISH")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/receiving_server_packet.rs b/mqtt-tester/src/behaviour/receiving_server_packet.rs index ee1e981..d2fdc03 100644 --- a/mqtt-tester/src/behaviour/receiving_server_packet.rs +++ b/mqtt-tester/src/behaviour/receiving_server_packet.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::{ connect_return::MConnectReturnCode, identifier::MPacketIdentifier, @@ -33,7 +34,8 @@ impl BehaviourTest for ReceivingServerPacket { session_present: false, connect_return_code: MConnectReturnCode::Accepted, }) - .await?; + .await + .context("Sending packet CONNACK")?; input .send_packet(MSubscribe { @@ -43,7 +45,8 @@ impl BehaviourTest for ReceivingServerPacket { data: b"a/b", }, }) - .await?; + .await + .context("Sending packet SUBSCRIBE")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/utf8_with_nullchar_is_rejected.rs b/mqtt-tester/src/behaviour/utf8_with_nullchar_is_rejected.rs index 1f1ad34..3192b12 100644 --- a/mqtt-tester/src/behaviour/utf8_with_nullchar_is_rejected.rs +++ b/mqtt-tester/src/behaviour/utf8_with_nullchar_is_rejected.rs @@ -4,6 +4,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; use mqtt_format::v3::{ connect_return::MConnectReturnCode, header::MPacketKind, packet::MConnack, qos::MQualityOfService, @@ -31,7 +32,8 @@ impl BehaviourTest for Utf8WithNullcharIsRejected { session_present: false, connect_return_code: MConnectReturnCode::Accepted, }) - .await?; + .await + .context("Sending packet CONNACK")?; input .send(&[ @@ -51,7 +53,8 @@ impl BehaviourTest for Utf8WithNullcharIsRejected { 0b0000_0001, 0x1, // Payload ]) - .await?; + .await + .context("Sending broken packet PUBLISH")?; Ok(()) } diff --git a/mqtt-tester/src/behaviour/wait_for_connect.rs b/mqtt-tester/src/behaviour/wait_for_connect.rs index 1d643e3..e63c415 100644 --- a/mqtt-tester/src/behaviour/wait_for_connect.rs +++ b/mqtt-tester/src/behaviour/wait_for_connect.rs @@ -4,6 +4,8 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use miette::Context; + use crate::{ behaviour_test::BehaviourTest, command::{Input, Output}, @@ -41,6 +43,8 @@ impl BehaviourTest for WaitForConnect { }), ) .await + .context("Waiting for bytes to check") + .map_err(miette::Error::from) } fn report_name(&self) -> &str { |