diff --git a/test/test_bson.py b/test/test_bson.py index 89c0983ca5..fec84090d2 100644 --- a/test/test_bson.py +++ b/test/test_bson.py @@ -23,6 +23,7 @@ import os import pickle import re +import struct import sys import tempfile import uuid @@ -489,6 +490,33 @@ def test_basic_encode(self): b"\x00", ) + def test_bad_code(self): + # Assert that decoding invalid Code with scope does not include a field name. + def generate_payload(length: int) -> bytes: + string_size = length - 0x1E + + return bytes.fromhex( + struct.pack("