66from pydantic import ValidationError , create_model
77from typing_extensions import Type
88
9+ from lean_spec .subspecs .koalabear import Fp
910from lean_spec .types .boolean import Boolean
1011from lean_spec .types .collections import SSZList , SSZVector
1112from lean_spec .types .container import Container
@@ -149,6 +150,13 @@ class Uint8Vector2(SSZVector):
149150 LENGTH = 2
150151
151152
153+ class FpVector8 (SSZVector ):
154+ """A vector of exactly 8 Fp values."""
155+
156+ ELEMENT_TYPE = Fp
157+ LENGTH = 8
158+
159+
152160# Additional List classes for tests
153161class Uint8List32 (SSZList ):
154162 """A list with up to 32 Uint8 values."""
@@ -178,6 +186,13 @@ class BooleanList4(SSZList):
178186 LIMIT = 4
179187
180188
189+ class FpList8 (SSZList ):
190+ """A list with up to 8 Fp values."""
191+
192+ ELEMENT_TYPE = Fp
193+ LIMIT = 8
194+
195+
181196# Test data for the 'sig' vector test case
182197sig_test_data_list = [0 ] * 96
183198for i , v in {0 : 1 , 32 : 2 , 64 : 3 , 95 : 0xFF }.items ():
@@ -335,6 +350,12 @@ class TestSSZVectorSerialization:
335350 (FixedContainer (a = Uint8 (1 ), b = Uint16 (2 )), FixedContainer (a = Uint8 (3 ), b = Uint16 (4 ))),
336351 "010200030400" , # 010200 for first element, 030400 for second
337352 ),
353+ (
354+ FpVector8 ,
355+ (10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 ),
356+ "0a000000140000001e0000002800000032000000"
357+ "3c0000004600000050000000" ,
358+ ),
338359 ],
339360 )
340361 def test_fixed_size_element_vector_serialization (
@@ -372,7 +393,7 @@ def test_variable_size_element_vector_serialization(self) -> None:
372393 assert decoded == instance
373394
374395
375- class TestListSerialization :
396+ class TestSSZListSerialization :
376397 """Tests SSZ serialization and deserialization for the List type."""
377398
378399 @pytest .mark .parametrize (
@@ -397,6 +418,11 @@ class TestListSerialization:
397418 tuple (range (1 , 20 )),
398419 "" .join (i .to_bytes (32 , "little" ).hex () for i in range (1 , 20 )),
399420 ),
421+ (
422+ FpList8 ,
423+ (10 , 20 , 30 ),
424+ "0a000000140000001e000000" ,
425+ ),
400426 ],
401427 )
402428 def test_fixed_size_element_list_serialization (
0 commit comments