diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 088a8ca54..1b30d687a 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -104,7 +104,7 @@ def invalid_cases(): RandomizationMode.mode_nil_count, RandomizationMode.mode_one_count, RandomizationMode.mode_max_count]: - for offset_index in offsets: + for index, offset_index in enumerate(offsets): yield f'{name}_{mode.to_name()}_offset_{offset_index}_plus_one', \ invalid_test_case(lambda: mod_offset( b=serialize(container_case_fn(rng, mode, typ)), @@ -117,3 +117,20 @@ def invalid_cases(): offset_index=offset_index, change=lambda x: 0 )) + if index == 0: + yield f'{name}_{mode.to_name()}_offset_{offset_index}_minus_one', \ + invalid_test_case(lambda: mod_offset( + b=serialize(container_case_fn(rng, mode, typ)), + offset_index=offset_index, + change=lambda x: x - 1 + )) + if mode == RandomizationMode.mode_max_count: + serialized = serialize(container_case_fn(rng, mode, typ)) + serialized = serialized + serialized[:2] + yield f'{name}_{mode.to_name()}_last_offset_{offset_index}_overflow', \ + invalid_test_case(lambda: serialized) + if mode == RandomizationMode.mode_one_count: + serialized = serialize(container_case_fn(rng, mode, typ)) + serialized = serialized + serialized[:1] + yield f'{name}_{mode.to_name()}_last_offset_{offset_index}_wrong_byte_length', \ + invalid_test_case(lambda: serialized)