Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need new method Sniffer::has_message_type_with_remove #1336

Closed
plebhash opened this issue Jan 8, 2025 · 0 comments · Fixed by #1341
Closed

need new method Sniffer::has_message_type_with_remove #1336

plebhash opened this issue Jan 8, 2025 · 0 comments · Fixed by #1341

Comments

@plebhash
Copy link
Collaborator

plebhash commented Jan 8, 2025

while reviewing #1325 we detected the need for a new Sniffer method for Integration Tests

this should help us avoid repeating assertions across multiple tests with the sole purpose of popping from the Sniffer queue

@jbesraa wrote this draft on Discord:

    fn has_message_type_with_remove(&self, message_type: u8) -> bool {
        let has_message: bool = self
            .messages
            .safe_lock(|messages| {
                for (t, _) in messages.iter() {
                    if *t == message_type {
                        messages.retain(|(_, _)| false);
                        return true; // Exit early with `true`
                    }
                }
                false // Default value if no match is found
            })
            .unwrap();
        has_message
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done ✅
Development

Successfully merging a pull request may close this issue.

1 participant