From 98938bd5bb84aeabc4df9602ddc48a5fb3c79223 Mon Sep 17 00:00:00 2001 From: plebhash Date: Thu, 9 Jan 2025 11:21:33 -0300 Subject: [PATCH] `integration_tests_sv2` docs cleanup.. - improves wording on `Sniffer` docs, as it implied that messages from upstream are always a response, which is not true - adds some brief docs to `InterceptMessage` struct - removes links to private items (which generate warnings on `cargo doc`) --- roles/tests-integration/lib/sniffer.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/roles/tests-integration/lib/sniffer.rs b/roles/tests-integration/lib/sniffer.rs index 91110bad0..c85245b41 100644 --- a/roles/tests-integration/lib/sniffer.rs +++ b/roles/tests-integration/lib/sniffer.rs @@ -35,21 +35,22 @@ enum SnifferError { /// Allows to intercept messages sent between two roles. /// +/// Can be useful for testing purposes, as it allows to assert that the roles have sent specific +/// messages in a specific order and to inspect the messages details. +/// /// The downstream (or client) role connects to the [`Sniffer`] `listening_address` and the /// [`Sniffer`] connects to the `upstream` server. This way, the Sniffer can intercept messages sent -/// between the downstream and upstream roles. The downstream will send its messages to the -/// [`Sniffer`] which will save those in the `messages_from_downstream` aggregator and forward them -/// to the upstream role. When a response is received it is saved in `messages_from_upstream` and -/// forwarded to the downstream role. Both `messages_from_downstream` and `messages_from_upstream` -/// can be accessed as FIFO queues. +/// between the downstream and upstream roles. /// -/// In order to alter the messages sent between the roles, the [`Sniffer::intercept_messages`] -/// field can be used. It will look for the [`InterceptMessage::expected_message_type`] in the -/// specified [`InterceptMessage::direction`] and replace it with -/// [`InterceptMessage::replace_message`]. +/// Messages received from downstream are stored in the `messages_from_downstream` aggregator and +/// forward them to the upstream role. Alternatively, messages received from upstream are stored in +/// the `messages_from_upstream` and forwarded to the downstream role. Both +/// `messages_from_downstream` and `messages_from_upstream` aggregators can be accessed as FIFO +/// queues via [`Sniffer::next_message_from_downstream`] and +/// [`Sniffer::next_message_from_upstream`], respectively. /// -/// Can be useful for testing purposes, as it allows to assert that the roles have sent specific -/// messages in a specific order and to inspect the messages details. +/// In order to replace the messages sent between the roles, a set of [`InterceptMessage`] can be +/// used in [`Sniffer::new`]. #[derive(Debug, Clone)] pub struct Sniffer { identifier: String, @@ -61,6 +62,7 @@ pub struct Sniffer { intercept_messages: Vec, } +/// Allows [`Sniffer`] to replace some intercepted message before forwarding it. #[derive(Debug, Clone)] pub struct InterceptMessage { direction: MessageDirection,