Skip to content

Commit

Permalink
new(tests): migrate EOF "embedded container" tests
Browse files Browse the repository at this point in the history
Migrate EOFTests/efValidation/EOF1_embedded_container_.json.
  • Loading branch information
chfast committed Aug 26, 2024
1 parent e35feea commit b086cba
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions converted-ethereum-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ GeneralStateTests/stCreate2/call_then_create2_successful_then_returndatasize.jso
([#598](https://github.com/ethereum/execution-spec-tests/pull/598))
EOFTests/EIP3540/validInvalid.json

EOFTests/efValidation/EOF1_embedded_container_.json
EOFTests/efValidation/EOF1_eofcreate_valid_.json
EOFTests/efValidation/EOF1_truncated_section_.json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,64 @@ def test_wide_container(eof_test: EOFTestFiller, width: int, exception: EOFExcep
),
id="EOF1_eofcreate_valid_0",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container(sections=[Section.Code(Op.INVALID)])),
],
expected_bytecode="""
ef00010100040200010006030001001404000000008000016000e0000000ef0001010004020001000104
00000000800000fe""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="EOF1_embedded_container_0",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container(sections=[Section.Code(Op.INVALID)])),
Section.Data(custom_size=2),
],
expected_bytecode="""
ef00010100040200010006030001001404000200008000016000e0000000ef0001010004020001000104
00000000800000fe""",
# Originally this test was "valid" but against the current spec
# it contains two errors: data section truncated and orphan subcontainer.
validity_error=EOFException.TOPLEVEL_CONTAINER_TRUNCATED,
),
id="EOF1_embedded_container_1",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container(sections=[Section.Code(Op.INVALID)])),
Section.Data("aabb"),
],
expected_bytecode="""
ef00010100040200010006030001001404000200008000016000e0000000ef0001010004020001000104
00000000800000feaabb""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="EOF1_embedded_container_2",
),
pytest.param(
Container(
sections=[
Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
Section.Container("aabbccddeeff"),
],
# The original test has been modified to reference the subcontainer by EOFCREATE.
validity_error=EOFException.INVALID_MAGIC,
),
id="EOF1_embedded_container_3",
),
pytest.param(
Container(
sections=[
Expand All @@ -603,6 +661,24 @@ def test_wide_container(eof_test: EOFTestFiller, width: int, exception: EOFExcep
),
id="EOF1_eofcreate_valid_1",
),
pytest.param(
Container(
sections=[
Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP),
Section.Container(Container(sections=[Section.Code(Op.INVALID)])),
Section.Container(
Container(sections=[Section.Code(Op.PUSH0 + Op.PUSH0 + Op.RETURN)])
),
],
expected_bytecode="""
ef000101000402000100060300020014001604000000008000016000e0000000ef000101000402000100
010400000000800000feef0001010004020001000304000000008000025f5ff3""",
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="EOF1_embedded_container_4",
),
pytest.param(
Container(
sections=[
Expand All @@ -623,6 +699,16 @@ def test_wide_container(eof_test: EOFTestFiller, width: int, exception: EOFExcep
),
id="EOF1_eofcreate_valid_2",
),
pytest.param(
Container(
sections=[Section.Code(Op.PUSH1[0] + Op.RJUMP[0] + Op.STOP)]
+ 256 * [Section.Container(Container(sections=[Section.Code(Op.INVALID)]))],
# Originally this test was "valid" because it was created
# before "orphan subcontainer" rule was introduced.
validity_error=EOFException.ORPHAN_SUBCONTAINER,
),
id="EOF1_embedded_container_5",
),
],
)
def test_migrated_eofcreate(eof_test: EOFTestFiller, container: Container):
Expand Down

0 comments on commit b086cba

Please sign in to comment.