Repository navigation
tests: pin ipv6-route Source Route tuple/list address packing - #485
Merged
Merged
Conversation
…480) - #480 widened Schema.pack's ListField branch to accept a tuple, but the one consumer with a tuple[...]-typed field against it -- SourceRoute.ip in ipv6_route's data model, backed by the ListField in its schema -- shipped on main with no test of its own. - Add a test exercising IPv6_Route.make -> Schema.pack for a Type 0 (Source Route) header, covering zero, one, and two addresses as both a tuple and a list, asserting the two forms pack byte-identical output, and round-tripping through Schema_SourceRoute.unpack to confirm the addresses come back in order. Ran tests/protocols/schema/ (25 passed) and tests/protocols/internet/test_ipv6_extension_unit.py (50 passed, 74 subtests) against the repo venv.
Owner
Author
|
Landed directly on Closing by hand because GitHub does not mark a PR merged when its commits arrive via a push rather than the merge button, even though they are genuinely on Before pushing I confirmed the change really is test-only and that it passes, rather than taking the branch's word for it:
|
This was referenced Sep 18, 2026
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.
Summary
Schema.pack'sListFieldbranch to accept atupleas well as alist(see schema: Schema.pack rejects the tuple its own data models declare, breaking parse-then-reconstruct for 16 HIP parameters #476), but the one consumer that ships atuple[...]-typed field against that branch landed onmainwith no test of its own:SourceRoute.ipinpcapkit/protocols/data/internet/ipv6_route.py(tuple[IPv6Address, ...]) is backed by theListFieldinSourceRouteinpcapkit/protocols/schema/internet/ipv6_route.py. Before schema: let ListField.pack accept the tuple its own data models declare #480, building a Type 0 (deprecated Source Route) routing header throughIPv6_Route.makewith a tuple of source addresses raisedProtocolUnbound; the same call with a list succeeded.test_ipv6_route_source_route_make_accepts_tuple_and_list_addressestotests/protocols/internet/test_ipv6_extension_unit.py, exercisingIPv6_Route.make→Schema.pack(the public construction pathipv6_route.pyactually uses) rather than buildingSchema_SourceRoutedirectly. It covers zero, one, and two addresses as both a tuple and a list, asserts the two forms pack byte-identical output (the real invariant schema: let ListField.pack accept the tuple its own data models declare #480 established), and round-trips the packed bytes back throughSchema_SourceRoute.unpackto confirm the addresses come back in the same order.ListFieldbranch inpcapkit/protocols/schema/schema.pyback toisinstance(data, list)makes all three subtests fail withpcapkit.utilities.exceptions.ProtocolUnbound: unsupported type <class 'tuple'>; restoring the file viagit checkout --brings it back to green. No source underpcapkit/is changed by this PR.A separate, pre-existing issue found (not fixed here)
While building the round trip, I found that a full
IPv6_Routeread of a Source-Route header (_read_data_type_src's(header.length - 8) % 16check) rejects everylengththatIPv6_Route.makeitself computes for this routing type, for any address count and regardless of tuple vs. list — e.g.makecomputeslength=20for a single address, and_read_data_type_srcrequires(length - 8) % 16 == 0, which no non-negativelengthof the form4 + 16*never satisfies. The same category of mismatch shows up in_read_data_type_2(header.length != 24) for the analogousType2routing data. This looks unrelated to #476/#480 and I have not touched it; the new test avoids it by round-tripping throughSchema_SourceRoute.unpackdirectly instead of a fullIPv6_Routeread.Test plan
PYTHONPATH=<worktree> .venv/bin/python -m pytest tests/protocols/schema/— 25 passedPYTHONPATH=<worktree> .venv/bin/python -m pytest tests/protocols/internet/test_ipv6_extension_unit.py— 50 passed, 74 subtestsListFieldfix locally, confirmed the new test fails with the pre-fixProtocolUnbounderror, then restored the file withgit checkout --and confirmed the test passes again