tests/foundation/engines/test_new_engine_parity_runtime.py:82's mac() helper assumes pypcapfile's Ethernet.dst/.src are raw 6-byte values needing hex-formatting. They are already colon-separated ASCII.
Confirmed at source — pcapfile/protocols/linklayer/ethernet.py, Ethernet.__init__:
(dst, src, self.type) = struct.unpack('!6s6sH', packet[:14])
dst = bytearray(dst); src = bytearray(src)
self.dst = b':'.join([('%02x' % o).encode('ascii') for o in dst])
self.src = b':'.join([('%02x' % o).encode('ascii') for o in src])
So .dst is b'40:33:1a:d1:85:1c', and mac() hex-encodes that a second time — producing '33:34:3a:...' against an expected '40:33:1a:d1:85:1c'. This is unconditional in pypcapfile and independent of layers=.
Why this matters for the other two
test_pypcapfile_agrees_with_the_default_engine is one of three HAS_PYPCAPFILE-gated parity methods, and each of the three needs a different fix:
| test |
needs |
test_pypcapfile_agrees_with_the_default_engine |
this issue |
ipv4_reassembly parity |
#746 (engine hexlify) + #743 (toolkit addresses) |
traces_only parity |
#746 + #743 |
Measured on 3.10.21: with #746's fix alone the Ethernet fields decode correctly but the other two hit #743's AddressValueError; overlaying #747's toolkit fix takes both fully green. This one stays red regardless, because neither the engine nor the toolkit can reach it.
So "the three parity tests go green" was the wrong acceptance criterion for #746 — I set it, and it was only ever true for two of them, and only in combination with #747. Correcting that here rather than leaving it implied.
Scope note
The fix is almost certainly deleting the re-encoding in mac() rather than changing library code — the library is right and the test is wrong. Worth confirming whether mac() is also applied to the default engine's output in the same comparison, because if so it may be correct for one side and wrong for the other, which would make a bare deletion break the other half.
Found while fixing #746 (PR #748), which correctly did not edit this file.
tests/foundation/engines/test_new_engine_parity_runtime.py:82'smac()helper assumespypcapfile'sEthernet.dst/.srcare raw 6-byte values needing hex-formatting. They are already colon-separated ASCII.Confirmed at source —
pcapfile/protocols/linklayer/ethernet.py,Ethernet.__init__:So
.dstisb'40:33:1a:d1:85:1c', andmac()hex-encodes that a second time — producing'33:34:3a:...'against an expected'40:33:1a:d1:85:1c'. This is unconditional inpypcapfileand independent oflayers=.Why this matters for the other two
test_pypcapfile_agrees_with_the_default_engineis one of threeHAS_PYPCAPFILE-gated parity methods, and each of the three needs a different fix:test_pypcapfile_agrees_with_the_default_engineipv4_reassemblyparitytraces_onlyparityMeasured on 3.10.21: with #746's fix alone the Ethernet fields decode correctly but the other two hit #743's
AddressValueError; overlaying #747's toolkit fix takes both fully green. This one stays red regardless, because neither the engine nor the toolkit can reach it.So "the three parity tests go green" was the wrong acceptance criterion for #746 — I set it, and it was only ever true for two of them, and only in combination with #747. Correcting that here rather than leaving it implied.
Scope note
The fix is almost certainly deleting the re-encoding in
mac()rather than changing library code — the library is right and the test is wrong. Worth confirming whethermac()is also applied to the default engine's output in the same comparison, because if so it may be correct for one side and wrong for the other, which would make a bare deletion break the other half.Found while fixing #746 (PR #748), which correctly did not edit this file.