Skip to content

Commit

Permalink
fix(tests): EOF - EIP-3540: Fix test ids
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Aug 16, 2024
1 parent 9316ab4 commit cccb738
Showing 1 changed file with 50 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
),
None,
id="EOF1V3540_0001",
id="EOF1V3540_0001_deployed_code_without_data_section",
),
pytest.param(
# Deployed code with data section
Expand All @@ -41,7 +41,7 @@
],
),
None,
id="EOF1V3540_0002",
id="EOF1V3540_0002_deployed_code_with_data_section",
),
pytest.param(
# No data section contents
Expand All @@ -53,7 +53,7 @@
],
),
EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
id="EOF1V3540_0003",
id="EOF1V3540_0003_no_data_section_contents",
),
pytest.param(
# Data section contents incomplete
Expand All @@ -65,13 +65,13 @@
],
),
EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
id="EOF1V3540_0004",
id="EOF1V3540_0004_data_section_contents_incomplete",
),
pytest.param(
# Type section size incomplete
bytes.fromhex("ef00010100"),
EOFException.INCOMPLETE_SECTION_SIZE,
id="EOF1I3540_0011",
id="EOF1I3540_0011_type_section_size_incomplete",
),
pytest.param(
# Empty code section with non-empty data section
Expand All @@ -80,129 +80,131 @@
expected_bytecode="ef000101000402000100000400020000000000aabb",
),
EOFException.ZERO_SECTION_SIZE,
id="EOF1I3540_0012",
id="EOF1I3540_0012_empty_code_section_with_non_empty_data_section",
),
pytest.param(
Container(
name="EOF1I3540_0014 (Invalid) Total of code sections incomplete",
raw_bytes="ef00010100040200",
),
EOFException.INCOMPLETE_SECTION_NUMBER,
id="EOF1I3540_0014_total_of_code_sections_incomplete",
),
pytest.param(
Container(
name="EOF1I3540_0016 (Invalid) Code section size incomplete",
raw_bytes="0xef000101000402000100",
),
EOFException.INCOMPLETE_SECTION_SIZE,
id="EOF1I3540_0016_code_section_size_incomplete",
),
pytest.param(
# No data section after code section size
bytes.fromhex("ef00010100040200010001"),
EOFException.MISSING_HEADERS_TERMINATOR,
id="EOF1I3540_0017",
id="EOF1I3540_0017_no_data_section_after_code_section_size",
),
pytest.param(
# No data size
bytes.fromhex("ef0001010004020001000104"),
EOFException.MISSING_HEADERS_TERMINATOR,
id="EOF1I3540_0018",
id="EOF1I3540_0018_no_data_size",
),
pytest.param(
# Data size incomplete
bytes.fromhex("ef000101000402000100010400"),
EOFException.INCOMPLETE_SECTION_SIZE,
id="EOF1I3540_0019",
id="EOF1I3540_0019_data_size_incomplete",
),
pytest.param(
# No section terminator after data section size
bytes.fromhex("ef00010100040200010001040002"),
EOFException.MISSING_HEADERS_TERMINATOR,
id="EOF1I3540_0020",
id="EOF1I3540_0020_no_section_terminator_after_data_section_size",
),
pytest.param(
# No type section contents
bytes.fromhex("ef0001010004020001000104000200"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0021",
id="EOF1I3540_0021_no_type_section_contents",
),
pytest.param(
# Type section contents (no outputs and max stack)
bytes.fromhex("ef000101000402000100010400020000"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0022",
id="EOF1I3540_0022_invalid_type_section_no_outputs_and_max_stack",
),
pytest.param(
# Type section contents (no max stack)
bytes.fromhex("ef00010100040200010001040002000000"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0023",
id="EOF1I3540_0023_invalid_type_section_no_max_stack",
),
pytest.param(
# Type section contents (max stack incomplete)
bytes.fromhex("ef0001010004020001000104000200000000"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0024",
id="EOF1I3540_0024_invalid_type_section_max_stack_incomplete",
),
pytest.param(
# No code section contents
bytes.fromhex("ef000101000402000100010400020000000000"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0025",
id="EOF1I3540_0025_no_code_section_contents",
),
pytest.param(
# Code section contents incomplete
bytes.fromhex("ef0001010004020001002904000000000000027f"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0026",
id="EOF1I3540_0026_code_section_contents_incomplete",
),
pytest.param(
# Trailing bytes after code section
bytes.fromhex("ef0001 010004 0200010001 040000 00 00800000 fe aabbcc"),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0027",
id="EOF1I3540_0027_trailing_bytes_after_code_section",
),
pytest.param(
# Trailing bytes after code section with wrong first section type
bytes.fromhex("ef0001 010004 0200010001 040000 00 00000000 fe aabbcc"),
EOFException.INVALID_FIRST_SECTION_TYPE,
id="EOF1I3540_0027_orig",
id="EOF1I3540_0027_trailing_bytes_after_code_section_with_wrong_first_section_type",
),
pytest.param(
# Empty code section
bytes.fromhex("ef000101000402000100000400000000000000"),
EOFException.ZERO_SECTION_SIZE,
id="EOF1I3540_0028",
id="EOF1I3540_0028_empty_code_section",
),
pytest.param(
# Code section preceding type section
bytes.fromhex("ef000102000100010100040400020000000000feaabb"),
EOFException.MISSING_TYPE_HEADER,
id="EOF1I3540_0030",
id="EOF1I3540_0030_code_section_preceding_type_section",
),
pytest.param(
# Data section preceding type section
bytes.fromhex("ef000104000201000402000100010000000000feaabb"),
EOFException.MISSING_TYPE_HEADER,
id="EOF1I3540_0031",
id="EOF1I3540_0031_data_section_preceding_type_section",
),
pytest.param(
# Data section preceding code section
bytes.fromhex("ef000101000404000202000100010000000000feaabb"),
EOFException.MISSING_CODE_HEADER,
id="EOF1I3540_0032",
id="EOF1I3540_0032_data_section_preceding_code_section",
),
pytest.param(
# Data section without code section
bytes.fromhex("ef00010100040400020000000000aabb"),
EOFException.MISSING_CODE_HEADER,
id="EOF1I3540_0033",
id="EOF1I3540_0033_data_section_without_code_section",
),
pytest.param(
# No data section
bytes.fromhex("ef000101000402000100010000000000fe"),
EOFException.MISSING_DATA_SECTION,
id="EOF1I3540_0034",
id="EOF1I3540_0034_no_data_section",
),
pytest.param(
# Trailing bytes after data section
Expand All @@ -215,97 +217,97 @@
expected_bytecode="ef0001 010004 0200010001 040002 00 00800000 fe aabbccdd",
),
EOFException.INVALID_SECTION_BODIES_SIZE,
id="EOF1I3540_0035",
id="EOF1I3540_0035_trailing_bytes_after_data_section",
),
pytest.param(
# Trailing bytes after data section with wrong first section type
bytes.fromhex("ef0001 010004 0200010001 040002 00 00000000 fe aabbccdd"),
EOFException.INVALID_FIRST_SECTION_TYPE,
id="EOF1I3540_0035_orig",
id="EOF1I3540_0035_trailing_bytes_after_data_section_with_wrong_first_section_type",
),
pytest.param(
# Multiple data sections
bytes.fromhex("ef000101000402000100010400020400020000000000feaabbaabb"),
EOFException.MISSING_TERMINATOR,
id="EOF1I3540_0036",
id="EOF1I3540_0036_multiple_data_sections",
),
pytest.param(
# Multiple code and data sections
bytes.fromhex("ef000101000802000200010001040002040002000000000000000000fefeaabbaabb"),
EOFException.MISSING_TERMINATOR,
id="EOF1I3540_0037",
id="EOF1I3540_0037_multiple_code_and_data_sections",
),
pytest.param(
# Unknown section ID (at the beginning)
bytes.fromhex("ef000105000101000402000100010400000000000000fe"),
EOFException.MISSING_TYPE_HEADER,
id="EOF1I3540_0038",
id="EOF1I3540_0038_unknown_section_id_at_the_beginning_05",
),
pytest.param(
# Unknown section ID (at the beginning)
bytes.fromhex("ef000106000101000402000100010400000000000000fe"),
EOFException.MISSING_TYPE_HEADER,
id="EOF1I3540_0039",
id="EOF1I3540_0039_unknown_section_id_at_the_beginning_06",
),
pytest.param(
# Unknown section ID (at the beginning)
bytes.fromhex("ef0001ff000101000402000100010400000000000000fe"),
EOFException.MISSING_TYPE_HEADER,
id="EOF1I3540_0040",
id="EOF1I3540_0040_unknown_section_id_at_the_beginning_ff",
),
pytest.param(
# Unknown section ID (after types section)
bytes.fromhex("ef000101000405000102000100010400000000000000fe"),
EOFException.MISSING_CODE_HEADER,
id="EOF1I3540_0041",
id="EOF1I3540_0041_unknown_section_id_after_types_section_05",
),
pytest.param(
# Unknown section ID (after types section)
bytes.fromhex("ef000101000406000102000100010400000000000000fe"),
EOFException.MISSING_CODE_HEADER,
id="EOF1I3540_0042",
id="EOF1I3540_0042_unknown_section_id_after_types_section_06",
),
pytest.param(
# Unknown section ID (after types section)
bytes.fromhex("ef0001010004ff000102000100010400000000000000fe"),
EOFException.MISSING_CODE_HEADER,
id="EOF1I3540_0043",
id="EOF1I3540_0043_unknown_section_id_after_types_section_ff",
),
pytest.param(
# Unknown section ID (after code section)
bytes.fromhex("ef000101000402000100010500010400000000000000fe"),
EOFException.MISSING_DATA_SECTION,
id="EOF1I3540_0044",
id="EOF1I3540_0044_unknown_section_id_after_code_section_05",
),
pytest.param(
# Unknown section ID (after code section)
bytes.fromhex("ef000101000402000100010600010400000000000000fe"),
EOFException.MISSING_DATA_SECTION,
id="EOF1I3540_0045",
id="EOF1I3540_0045_unknown_section_id_after_code_section_06",
),
pytest.param(
# Unknown section ID (after code section)
bytes.fromhex("ef00010100040200010001ff00010400000000000000fe"),
EOFException.MISSING_DATA_SECTION,
id="EOF1I3540_0046",
id="EOF1I3540_0046_unknown_section_id_after_code_section_ff",
),
pytest.param(
# Unknown section ID (after data section)
bytes.fromhex("ef000101000402000100010400000500010000000000fe"),
EOFException.MISSING_TERMINATOR,
id="EOF1I3540_0047",
id="EOF1I3540_0047_unknown_section_id_after_data_section_05",
),
pytest.param(
# Unknown section ID (after data section)
bytes.fromhex("ef000101000402000100010400000600010000000000fe"),
EOFException.MISSING_TERMINATOR,
id="EOF1I3540_0048",
id="EOF1I3540_0048_unknown_section_id_after_data_section_06",
),
pytest.param(
# Unknown section ID (after data section)
bytes.fromhex("ef00010100040200010001040000ff00010000000000fe"),
EOFException.MISSING_TERMINATOR,
id="EOF1I3540_0049",
id="EOF1I3540_0049_unknown_section_id_after_data_section_ff",
),
# TODO: Duplicated tests
# The following test cases are duplicates but added to confirm test coverage is retained.
Expand All @@ -315,55 +317,63 @@
raw_bytes="ef",
),
EOFException.INVALID_MAGIC,
id="EOF1I3540_0001_invalid_no_magic",
),
pytest.param(
Container(
name="EOF1I3540_0002 (Invalid) Invalid magic",
raw_bytes="ef010101000402000100010400000000000000fe",
),
EOFException.INVALID_MAGIC,
id="EOF1I3540_0002_invalid_incorrect_magic_01",
),
pytest.param(
Container(
name="EOF1I3540_0003",
raw_bytes="ef020101000402000100010400000000000000fe",
),
EOFException.INVALID_MAGIC,
id="EOF1I3540_0003_invalid_incorrect_magic_02",
),
pytest.param(
Container(
name="EOF1I3540_0004",
raw_bytes="efff0101000402000100010400000000000000fe",
),
EOFException.INVALID_MAGIC,
id="EOF1I3540_0004_invalid_incorrect_magic_ff",
),
pytest.param(
Container(
name="EOF1I3540_0005 (Invalid) No version",
raw_bytes="ef00",
),
EOFException.INVALID_VERSION,
id="EOF1I3540_0005_invalid_no_version",
),
pytest.param(
Container(
name="EOF1I3540_0006 (Invalid) Invalid version",
raw_bytes="ef000001000402000100010400000000000000fe",
),
EOFException.INVALID_VERSION,
id="EOF1I3540_0006_invalid_incorrect_version_00",
),
pytest.param(
Container(
name="EOF1I3540_0007",
raw_bytes="ef000201000402000100010400000000000000fe",
),
EOFException.INVALID_VERSION,
id="EOF1I3540_0007_invalid_incorrect_version_02",
),
pytest.param(
Container(
name="EOF1I3540_0008",
raw_bytes="ef00ff01000402000100010400000000000000fe",
),
EOFException.INVALID_VERSION,
id="EOF1I3540_0008_invalid_incorrect_version_ff",
),
],
)
Expand Down

0 comments on commit cccb738

Please sign in to comment.