protocols/autonat: Fix flaky test #2660
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aOutboundProbeEvent::Response
and as a result theEvent::StatusChanged
can be reported before the related inbound connection event.Change checklist