test: cover scope_id ipv6 dedupe partial branches#1766
Closed
bdraco wants to merge 2 commits into
Closed
Conversation
When the same link-local IPv6 address arrives as two DNSAddress records — once over an IPv4 socket (scope_id=None) and once over an IPv6 socket (scope_id=interface index) — the cache stored both and ServiceInfo would either return both copies or silently drop the scoped variant, leaving parsed_scoped_addresses() unable to return the %<interface_index>-qualified address its docstring promises. Collapse the two variants in _get_ip_addresses_from_cache_lifo() and _process_record_threadsafe() by matching addresses on their packed integer (ignoring scope_id) and keeping the entry that carries a scope_id when one is available. Fixes #1567
Add a cache LIFO case where a scoped AAAA is encountered before its unscoped twin so the unscoped variant fails the _has_more_scope_info check and the scoped entry stays in place. Add a direct call against _has_more_scope_info with an IPv4 address so its non-IPv6 short-circuit return is exercised.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1766 +/- ##
=======================================
Coverage 99.77% 99.77%
=======================================
Files 33 33
Lines 3509 3534 +25
Branches 493 498 +5
=======================================
+ Hits 3501 3526 +25
Misses 5 5
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes the codecov gap on #1764.
test_scoped_address_kept_when_unscoped_arrives_after_in_cache pins the False branch of _has_more_scope_info inside _get_ip_addresses_from_cache_lifo, where the cache returns the scoped AAAA before the unscoped twin; test_has_more_scope_info_returns_false_for_ipv4 exercises the IPv4 path inside the helper itself.
Stacks on #1764; merge after that lands.
Test plan
poetry run pytest tests/services/test_info.py, 37 passed.
SKIP_CYTHON=1 poetry run pytest tests/services/test_info.py, 37 passed.