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

protocols/autonat: Fix flaky test #2660

Merged
merged 2 commits into from
May 22, 2022

Conversation

elenaf9
Copy link
Contributor

@elenaf9 elenaf9 commented May 19, 2022

Description

Follow-up on #2658 (comment).
In rare cases (that only really happen in a test setup where both peers may run in the same thread) the server may observe a connection (which indicates a successful dial attempt) and already report the response back to the client, before the inbound connection event is reported at the client. Most likely occurring now because with #2627 the behaviour (where we receive the server's response) is polled before the pool (that reports the established connection).
I assume that in the real world this is not relevant because it would take much longer for the server to send the response back and in the meantime the client would already have reported the inbound connection.

Handle in the autonat test_client::test_auto_probe that a OutboundProbeEvent::Response and as a result the Event::StatusChanged can be reported before the related inbound connection event.

Change checklist

  • I have performed a self-review of my own code

Handle in test that a `OutboundProbeEvent::Response` can be reported
before the associated inbound connection event.
In rare cases (that only really happen in a test setup where both peers
run on the same device) the server may observe a connection and report
the response back to the client, before the connection event was
reported at the client.
@thomaseizinger thomaseizinger changed the title autonat: fix flaky test protocols/autonat: Fix flaky test May 20, 2022
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. Thanks for debugging this and thanks for the great explainer.

@mxinden mxinden merged commit 48598fc into libp2p:master May 22, 2022
@elenaf9 elenaf9 deleted the autonat/fix-client-test branch May 22, 2022 19:17
umgefahren pushed a commit to umgefahren/rust-libp2p that referenced this pull request Mar 8, 2024
Handle in test that a `OutboundProbeEvent::Response` can be reported
before the associated inbound connection event.
In rare cases (that only really happen in a test setup where both peers
run on the same device) the server may observe a connection and report
the response back to the client, before the connection event was
reported at the client.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants