Skip to content

Commit

Permalink
integration_tests_sv2 docs cleanup..
Browse files Browse the repository at this point in the history
- 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`)
  • Loading branch information
plebhash committed Jan 9, 2025
1 parent 85433a8 commit 98938bd
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions roles/tests-integration/lib/sniffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -61,6 +62,7 @@ pub struct Sniffer {
intercept_messages: Vec<InterceptMessage>,
}

/// Allows [`Sniffer`] to replace some intercepted message before forwarding it.
#[derive(Debug, Clone)]
pub struct InterceptMessage {
direction: MessageDirection,
Expand Down

0 comments on commit 98938bd

Please sign in to comment.