]> Cypherpunks repositories - keks.git/commitdiff
Add junk during UUID decoding
authorSergey Matveev <stargrave@stargrave.org>
Sat, 30 Nov 2024 16:45:35 +0000 (19:45 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 30 Nov 2024 19:38:56 +0000 (22:38 +0300)
pyac/tests/test_uuid.py

index f0263cfae9fa730bd8fa44671cbfb71cbdf13be51881adc315930a6d3da170e5..a519ec4276836499f0c5bc1b0395641a7254c535917ddedfa20e0e84a4dac74f 100644 (file)
@@ -1,9 +1,12 @@
 from unittest import TestCase
 from uuid import UUID
 
+from hypothesis import given
+
 from pyac import dumps
 from pyac import loads
 from pyac import NotEnoughData
+from tests.strategies import junk_st
 
 
 class TestUUID(TestCase):
@@ -13,12 +16,14 @@ class TestUUID(TestCase):
         encoded: bytes = dumps(uuid_obj)
         self.assertSequenceEqual(encoded, b"\x04\x124Vx\x124Vx\x124Vx\x124Vx")
 
-    def test_uuid_decode(self) -> None:
+    @given(junk_st)
+    def test_uuid_decode(self, junk: bytes) -> None:
         uuid_str: str = "12345678-1234-5678-1234-567812345678"
         encoded: bytes = b"\x04\x124Vx\x124Vx\x124Vx\x124Vx"
         decoded: UUID
-        decoded, _ = loads(encoded)
+        decoded, tail = loads(encoded + junk)
         self.assertEqual(decoded, UUID(uuid_str))
+        self.assertSequenceEqual(tail, junk)
 
     def test_uuid_not_enough_data(self) -> None:
         encoded: bytes = b"\x04\x124Vx\x124Vx\x124Vx\x124V"