test(tcp): retarget the last assertion pinning the old padding side (#604) - #628
Merged
Merged
Conversation
…604) * `TCPUDPUnitTests.test_a_truncated_option_still_parses_its_declared_length` expected a truncated TCP option's `data` as the synthesised zero octets followed by the real ones, which is what `rjust()` produced. #621 made the padding `ljust()` everywhere but could not retarget this file, because #612 owned it at the time; it has been red on `main` since #621 merged. * The real octets now come first for both parametrised widths, and the docstring above the assertion says tail-padding rather than left-padding. * Test-only: no library code changes. The sibling case in `tests/protocols/internet/test_ipv4_unit.py` was already retargeted in #621. Measured against `main` at 2221c2d: two subtest failures before, none after. `tests/protocols/transport/` and `tests/corekit/test_fields_field.py` together give 177 passed, 232 subtests passed.
This was referenced Sep 22, 2026
This was referenced Sep 22, 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.
Follow-up to #621, which fixed #604.
mainis red without this.What is broken on
mainTCPUDPUnitTests.test_a_truncated_option_still_parses_its_declared_length(
tests/protocols/transport/test_tcp_udp_unit.py:1415onmain) pins the paddingside that #604 corrected:
A truncated TCP option's
datais the octets that were actually read followed bythe zeros synthesised for the ones that were not —
rjust()produced the reverse,and #621 changed
FieldBase.unpacktoljust(). Both parametrised widths(
declared_length=12and32) therefore fail.Measured against
mainat2221c2d8f, from agit archiveexport withpcapkit.__file__asserted inside the export before any other import:Why it was not in #621
#621 deliberately left it. This file was concurrently owned by #612 at the time,
and editing it would have risked discarding work that has since merged — #621's
own body called that out and named the exact one-line change needed. #612 merged,
and then #621 merged before the follow-up could be folded into it, so the
correction lands here instead.
The change
trailing + b'\x00' * zeroes, for both widths.FieldBase.unpack"left-pads the short read … adatavalue of four zero octets followed by the six real ones". It now saystail-pads, and the six real octets followed by four zero ones, with a note that
before FieldBase.unpack pads a short read with rjust regardless of byte order, silently corrupting little-endian values #604 it was the other way round.
CHANGELOG.mdregenerated withutil/changelog_md.py(
--checkexits 0).Test-only — no library code changes. The sibling case in
tests/protocols/internet/test_ipv4_unit.pywas already retargeted in #621, andbytes(proto.__header__) == rawon the line below the changed assertion passesuntouched, since the pack path is byte-preserving and is not affected by the
padding side.
Verification
Run with
PYTHONSAFEPATH=1andPYTHONPATHset to the tree under test, withpcapkit.__file__and the padding side both asserted before the run — thismachine's venv editable install otherwise resolves
pcapkitto a checkout that isbehind
origin/main, which silently invalidates a bare run.