Skip to content

Commit 851fe67

Browse files
committed
tests: add test_execute_message_v5_skip_meta_sets_flag
Before this PR, _SKIP_METADATA_FLAG was never written to the wire — the skip_meta field existed on _QueryMessage but _write_query_params did not use it. The PR activates it for the first time for all protocol versions. The new test pins the v5 wire encoding: skip_meta=True must produce a 4-byte flags word of 0x00000003 (VALUES_FLAG | SKIP_METADATA_FLAG), alongside the always-present result_metadata_id sentinel for v5.
1 parent 72100cb commit 851fe67

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/unit/test_protocol.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,32 @@ def test_execute_message_skip_meta_flag(self):
8282
# flags byte should be VALUES_FLAG | SKIP_METADATA_FLAG = 0x01 | 0x02 = 0x03
8383
self._check_calls(mock_io, [(b'\x00\x01',), (b'1',), (b'\x00\x04',), (b'\x03',), (b'\x00\x00',)])
8484

85+
def test_execute_message_v5_skip_meta_sets_flag(self):
86+
"""
87+
On protocol v5, skip_meta=True must set _SKIP_METADATA_FLAG in the
88+
4-byte flags word. This confirms that _SKIP_METADATA_FLAG is actually
89+
written to the wire (it was dead code in upstream before this PR).
90+
91+
v5 always writes result_metadata_id (None → empty sentinel b'') and uses
92+
a 4-byte int for flags instead of a 1-byte field.
93+
"""
94+
message = ExecuteMessage('1', [], 4, skip_meta=True)
95+
mock_io = Mock()
96+
97+
message.send_body(mock_io, 5)
98+
# v5 wire layout:
99+
# query_id: short(1) + b'1'
100+
# result_metadata_id: short(0) + b'' (sentinel — None on init)
101+
# consistency: short(4) = ONE
102+
# flags (4-byte int): VALUES_FLAG(0x01) | SKIP_METADATA_FLAG(0x02) = 0x03
103+
# param count: short(0)
104+
self._check_calls(mock_io, [
105+
(b'\x00\x01',), (b'1',),
106+
(b'\x00\x00',), (b'',),
107+
(b'\x00\x04',),
108+
(b'\x00\x00\x00\x03',), (b'\x00\x00',),
109+
])
110+
85111
def test_execute_message_scylla_metadata_id_v4(self):
86112
"""result_metadata_id should be written on protocol v4 when use_metadata_id=True (Scylla extension)."""
87113
message = ExecuteMessage('1', [], 4)

0 commit comments

Comments
 (0)