Skip to content

Commit 21d233c

Browse files
test: add boundary tests for uint32 vs uint64 db_id across message types
ExecSqlRequest uses uint64 db_id (accepting values > 2^32-1) while ExecRequest uses uint32 db_id (rejecting them). Added tests verifying this protocol invariant to prevent accidental swaps of the validators. Closes #134 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9e67f28 commit 21d233c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/test_messages_requests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,18 @@ def test_valid_values_accepted(self) -> None:
521521
HeartbeatRequest(timestamp=0)
522522
OpenRequest(name="test.db", flags=0, vfs="")
523523

524+
def test_exec_sql_accepts_large_db_id(self) -> None:
525+
"""134: ExecSqlRequest uses uint64 db_id, accepting values > uint32 max."""
526+
msg = ExecSqlRequest(db_id=2**32, sql="SELECT 1")
527+
assert msg.db_id == 2**32
528+
529+
def test_exec_rejects_large_db_id(self) -> None:
530+
"""134: ExecRequest uses uint32 db_id, rejecting values > uint32 max."""
531+
import pytest
532+
533+
with pytest.raises(ValueError, match="db_id"):
534+
ExecRequest(db_id=2**32, stmt_id=0)
535+
524536
def test_bool_rejected_for_uint32_db_id(self) -> None:
525537
"""Bool must not be silently accepted as a uint32 field."""
526538
import pytest

0 commit comments

Comments
 (0)