From b220655d243eb36cac0d01a05324e0268b15d0e2 Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 13:08:47 +0100 Subject: [PATCH 01/10] Add 3 new invalid test cases --- tests/generators/ssz_generic/ssz_container.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 8f3a59ce3..9c1d9d0cb 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -105,7 +105,7 @@ def invalid_cases(): RandomizationMode.mode_one_count, RandomizationMode.mode_max_count]: if len(offsets) != 0: - 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)), @@ -118,3 +118,20 @@ def invalid_cases(): offset_index=offset_index, change=lambda x: 0 )) + if index == 0: + yield f'{name}_{mode.to_name()}_first 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[0: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[0:1] + yield f'{name}_{mode.to_name()}_last offset_{offset_index}_wrong_byte_length', \ + invalid_test_case(lambda:serialized) From 7ccd528cd15a7310e95aa07fdbc0c7971f163e89 Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 13:26:00 +0100 Subject: [PATCH 02/10] fixing lint --- tests/generators/ssz_generic/ssz_container.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 9c1d9d0cb..8c8ed0b46 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -105,7 +105,7 @@ def invalid_cases(): RandomizationMode.mode_one_count, RandomizationMode.mode_max_count]: if len(offsets) != 0: - for index,offset_index in enumerate(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)), @@ -120,7 +120,7 @@ def invalid_cases(): )) if index == 0: yield f'{name}_{mode.to_name()}_first offset_{offset_index}_minus_one', \ - invalid_test_case(lambda: mod_offset( + invalid_test_case(lambda: mod_offset( b=serialize(container_case_fn(rng, mode, typ)), offset_index=offset_index, change=lambda x: x - 1 @@ -129,9 +129,9 @@ def invalid_cases(): serialized = serialize(container_case_fn(rng, mode, typ)) serialized = serialized + serialized[0:2] yield f'{name}_{mode.to_name()}_last offset_{offset_index}_overflow', \ - invalid_test_case(lambda:serialized) + invalid_test_case(lambda: serialized) if mode == RandomizationMode.mode_one_count: serialized = serialize(container_case_fn(rng, mode, typ)) serialized = serialized + serialized[0:1] yield f'{name}_{mode.to_name()}_last offset_{offset_index}_wrong_byte_length', \ - invalid_test_case(lambda:serialized) + invalid_test_case(lambda: serialized) From b5908cf2948146c15b327a329c9303b4a0cd0d3c Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 13:28:19 +0100 Subject: [PATCH 03/10] fixing lint --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 8c8ed0b46..4cff3ed4a 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -124,7 +124,7 @@ def invalid_cases(): 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[0:2] From db16f590cbd32f15b1531a29541503ab5fbb1a76 Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 13:29:57 +0100 Subject: [PATCH 04/10] fixing lint --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 4cff3ed4a..59f53e66f 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -124,7 +124,7 @@ def invalid_cases(): 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[0:2] From 6f64d46bc470fbe8ba32d44b3c0fa3b3d45079cd Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 19:06:42 +0100 Subject: [PATCH 05/10] Update tests/generators/ssz_generic/ssz_container.py Co-authored-by: Alex Stokes --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 59f53e66f..2498d392b 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -119,7 +119,7 @@ def invalid_cases(): change=lambda x: 0 )) if index == 0: - yield f'{name}_{mode.to_name()}_first offset_{offset_index}_minus_one', \ + 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, From 22719f2748f932e3d37a05026a088f26ae18c22c Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 19:06:50 +0100 Subject: [PATCH 06/10] Update tests/generators/ssz_generic/ssz_container.py Co-authored-by: Alex Stokes --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 2498d392b..818361fda 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -127,7 +127,7 @@ def invalid_cases(): )) if mode == RandomizationMode.mode_max_count: serialized = serialize(container_case_fn(rng, mode, typ)) - serialized = serialized + serialized[0:2] + 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: From 7df0d4d70e60ff10d214578ec555b341d3b78f9d Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 19:07:23 +0100 Subject: [PATCH 07/10] Update tests/generators/ssz_generic/ssz_container.py Co-authored-by: Alex Stokes --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 818361fda..70e765c0c 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -128,7 +128,7 @@ def invalid_cases(): 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', \ + 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)) From 69a2fb4af09cb2c97d3a33c713917fa2512de4f7 Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 19:07:31 +0100 Subject: [PATCH 08/10] Update tests/generators/ssz_generic/ssz_container.py Co-authored-by: Alex Stokes --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 70e765c0c..72b1729a4 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -132,6 +132,6 @@ def invalid_cases(): invalid_test_case(lambda: serialized) if mode == RandomizationMode.mode_one_count: serialized = serialize(container_case_fn(rng, mode, typ)) - serialized = serialized + serialized[0:1] + serialized = serialized + serialized[:1] yield f'{name}_{mode.to_name()}_last offset_{offset_index}_wrong_byte_length', \ invalid_test_case(lambda: serialized) From e56dddd6ecd3b507721195f06782916b4dd8a5ae Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 6 Jan 2022 19:07:48 +0100 Subject: [PATCH 09/10] Update tests/generators/ssz_generic/ssz_container.py Co-authored-by: Alex Stokes --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index 72b1729a4..18fb3c09f 100644 --- a/tests/generators/ssz_generic/ssz_container.py +++ b/tests/generators/ssz_generic/ssz_container.py @@ -133,5 +133,5 @@ def invalid_cases(): 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', \ + yield f'{name}_{mode.to_name()}_last_offset_{offset_index}_wrong_byte_length', \ invalid_test_case(lambda: serialized) From 7255faf41b0e1aa3dc1bd12a823a98b459a45a70 Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Thu, 13 Jan 2022 13:40:48 +0100 Subject: [PATCH 10/10] Update ssz_container.py --- tests/generators/ssz_generic/ssz_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators/ssz_generic/ssz_container.py b/tests/generators/ssz_generic/ssz_container.py index b93399522..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)),