diff --git a/tests/protocols/misc/pcap/test_frame_length_runtime.py b/tests/protocols/misc/pcap/test_frame_length_runtime.py index f8a0fb0d13..83ffcf92e0 100644 --- a/tests/protocols/misc/pcap/test_frame_length_runtime.py +++ b/tests/protocols/misc/pcap/test_frame_length_runtime.py @@ -347,10 +347,7 @@ def test_block2frame_puts_the_on_wire_length_in_len(self) -> None: self.assertEqual(frame.frame_info.orig_len, block.original_len) self.assertGreaterEqual(frame.len, frame.cap_len) - # NOTE: no assertion that ``cap_len == len(frame.packet)`` here, - # which is the PCAP side's independent check. The octets a - # PCAP-NG block carries are #646's concern, pinned in - # tests/protocols/test_pcapng_regression.py rather than here. + self.assertEqual(frame.cap_len, len(frame.packet)) if block.captured_len != block.original_len: truncated += 1 diff --git a/tests/protocols/test_pcapng_regression.py b/tests/protocols/test_pcapng_regression.py index a87b1ea541..67857841c0 100644 --- a/tests/protocols/test_pcapng_regression.py +++ b/tests/protocols/test_pcapng_regression.py @@ -405,12 +405,12 @@ def test_dumped_pcap_carries_the_payload_octets(self) -> None: self.assertGreaterEqual(orig_len, incl_len) # 24 octets of global header, then 16 of record header and the payload per - # record, with nothing left over. Without the #646 fix this file is 88 octets - # for these four blocks -- the global header and four record headers, and not - # one octet of payload -- which is both the wrong size and, worse, a size a - # reader cannot tell is wrong until it has already lost frame sync. + # record, with nothing left over. This exact size is what catches #646: + # without the fix the file is the global header and one record header per + # block, and not one octet of payload -- which is both the wrong size and, + # worse, a size a reader cannot tell is wrong until it has already lost + # frame sync. self.assertEqual(len(dumped), 24 + sum(16 + len(payload) for payload in expected)) - self.assertNotEqual(len(dumped), 104) if __name__ == '__main__': diff --git a/tests/protocols/transport/test_sctp_unit.py b/tests/protocols/transport/test_sctp_unit.py index ca2f1fefb8..5ec87f4d3a 100644 --- a/tests/protocols/transport/test_sctp_unit.py +++ b/tests/protocols/transport/test_sctp_unit.py @@ -31,30 +31,6 @@ HAS_SCAPY = importlib.util.find_spec('scapy') is not None -def bitfield_packs_zero_bits() -> bool: - """Whether :class:`~pcapkit.corekit.fields.strings.BitField` packs a clear bit. - - It guards against a ``BitField.pre_process`` that seeds its working buffer - with NUL bytes and then writes the ASCII characters ``b'0'`` and ``b'1'`` - into it, before collapsing the buffer by truth-testing each byte -- ``b'0'`` - is ``0x30``, which is truthy, so every named bit comes out **set** regardless - of its value, and a flag word constructed with any bit clear does not survive - a round trip. - - That is a library-wide concern of :mod:`pcapkit.corekit`, not an SCTP one. - The tests that need clear bits on the *construction* side are gated on this - probe, so that they run wherever :mod:`pcapkit.corekit` packs clear bits - correctly. Parsing does not depend on it -- ``BitField.post_process`` reads - the bits separately -- so the wire-conformance and scapy cross-check tests - below exercise mixed flags unconditionally. - - """ - from pcapkit.corekit.fields.strings import BitField - - field = BitField(length=1, namespace={'a': (0, 1), 'b': (7, 1)}) - return field.pre_process({'a': 0, 'b': 1}, {}) == b'\x01' - - @unittest.skipUnless(HAS_RUNTIME, 'runtime dependencies not installed') class SCTPUnitTests(unittest.TestCase): # NOTE: Unlike the sibling TCP/UDP unit tests, this module does not purge @@ -246,11 +222,10 @@ def test_every_chunk_type_round_trips(self) -> None: from pcapkit.const.sctp.chunk import Chunk from pcapkit.const.sctp.parameter import Parameter - # Every flag in the flag-carrying chunks is set, so that these tests do - # not depend on the BitField construction probe - # :func:`bitfield_packs_zero_bits`; mixed flags are covered on the - # parsing side by the wire-conformance and scapy tests below, and on the - # construction side by the gated test that follows this one. + # Every flag in the flag-carrying chunks is set; mixed flags are covered + # on the parsing side by the wire-conformance and scapy tests below, and + # on the construction side by + # ``test_chunk_flags_round_trip_with_mixed_bits``. cases = [ (Chunk.Payload_Data, dict(I=True, U=True, B=True, E=True, tsn=0x0A0B0C0D, stream_id=1, @@ -329,10 +304,6 @@ def test_every_chunk_type_round_trips(self) -> None: def test_chunk_flags_round_trip_with_mixed_bits(self) -> None: from pcapkit.const.sctp.chunk import Chunk - if not bitfield_packs_zero_bits(): - self.skipTest('BitField.pre_process sets every named bit regardless ' - 'of value; see bitfield_packs_zero_bits()') - raw = self._build([(Chunk.Payload_Data, dict(I=False, U=False, B=True, E=True, tsn=1, data=b'x'))]) flags = self._packet(raw).info.chunks[Chunk.Payload_Data].flags