Skip to content

Commit ef3bf6a

Browse files
test: add codec-level round-trip tests for StmtResponse V1
The existing V1 test called decode_body directly, bypassing the _MAX_SCHEMA gate in decode_bytes. These new tests route StmtResponse with tail_offset through MessageDecoder.decode() and decode_message() to guard against regressions in the _MAX_SCHEMA dict. Closes #112 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 59162fa commit ef3bf6a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_codec.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,29 @@ def test_prepare_request_schema_survives_roundtrip(self) -> None:
636636
assert isinstance(decoded, PrepareRequest)
637637
assert decoded.schema == 1
638638

639+
def test_stmt_response_v1_through_codec(self) -> None:
640+
"""112: StmtResponse V1 must pass through the codec _MAX_SCHEMA gate."""
641+
msg = StmtResponse(db_id=1, stmt_id=2, num_params=3, tail_offset=42)
642+
encoded = msg.encode()
643+
644+
decoder = MessageDecoder(is_request=False)
645+
decoder.feed(encoded)
646+
decoded = decoder.decode()
647+
648+
assert isinstance(decoded, StmtResponse)
649+
assert decoded.db_id == 1
650+
assert decoded.stmt_id == 2
651+
assert decoded.num_params == 3
652+
assert decoded.tail_offset == 42
653+
654+
def test_stmt_response_v1_through_decode_message(self) -> None:
655+
"""112: StmtResponse V1 via decode_message convenience function."""
656+
msg = StmtResponse(db_id=1, stmt_id=2, num_params=3, tail_offset=42)
657+
encoded = msg.encode()
658+
decoded = decode_message(encoded)
659+
assert isinstance(decoded, StmtResponse)
660+
assert decoded.tail_offset == 42
661+
639662
def test_decode_bytes_slices_body_to_header_size(self) -> None:
640663
"""decode_bytes() must not pass trailing bytes to the message decoder.
641664

0 commit comments

Comments
 (0)