allow `container_case_fn` to change chaos mode

This commit is contained in:
WenceslasSANCHEZ 2023-08-01 21:44:35 +02:00
parent 6e4d4896ed
commit b412bdb34e
1 changed files with 3 additions and 3 deletions

View File

@ -46,11 +46,11 @@ class BitsStruct(Container):
E: Bitvector[8] E: Bitvector[8]
def container_case_fn(rng: Random, mode: RandomizationMode, typ: Type[View]): def container_case_fn(rng: Random, mode: RandomizationMode, typ: Type[View], chaos: bool=False):
return get_random_ssz_object(rng, typ, return get_random_ssz_object(rng, typ,
max_bytes_length=2000, max_bytes_length=2000,
max_list_length=2000, max_list_length=2000,
mode=mode, chaos=False) mode=mode, chaos=chaos)
PRESET_CONTAINERS: Dict[str, Tuple[Type[View], Sequence[int]]] = { PRESET_CONTAINERS: Dict[str, Tuple[Type[View], Sequence[int]]] = {
@ -79,7 +79,7 @@ def valid_cases():
valid_test_case(lambda: container_case_fn(rng, mode, typ)) valid_test_case(lambda: container_case_fn(rng, mode, typ))
for variation in range(3): for variation in range(3):
yield f'{name}_{mode.to_name()}_chaos_{variation}', \ yield f'{name}_{mode.to_name()}_chaos_{variation}', \
valid_test_case(lambda: container_case_fn(rng, mode, typ)) valid_test_case(lambda: container_case_fn(rng, mode, typ, chaos=True))
def mod_offset(b: bytes, offset_index: int, change: Callable[[int], int]): def mod_offset(b: bytes, offset_index: int, change: Callable[[int], int]):