Skip to content

Commit

Permalink
new(tests): Add test for valid subcontainer kinds in a non-first code…
Browse files Browse the repository at this point in the history
… section
  • Loading branch information
gumb0 committed Jul 10, 2024
1 parent a3fadea commit 9b070ad
Showing 1 changed file with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
EOF Subcontainer tests covering simple cases.
"""

import pytest

from ethereum_test_tools import Account, EOFException, EOFStateTestFiller, EOFTestFiller
Expand Down Expand Up @@ -97,9 +98,11 @@ def test_reverting_container(
zero_section,
revert_sub_container,
],
kind=ContainerKind.INITCODE
if zero_section == returncontract_code_section
else ContainerKind.RUNTIME,
kind=(
ContainerKind.INITCODE
if zero_section == returncontract_code_section
else ContainerKind.RUNTIME
),
),
container_post=Account(storage={slot_code_worked: value_code_worked}),
)
Expand Down Expand Up @@ -356,6 +359,57 @@ def test_container_combos_deeply_nested_invalid(
)


@pytest.mark.parametrize(
"code_section,first_sub_container,container_kind",
[
pytest.param(
eofcreate_code_section,
returncontract_sub_container,
ContainerKind.RUNTIME,
id="EOFCREATE/RETURNCONTRACT",
),
pytest.param(
returncontract_code_section,
stop_sub_container,
ContainerKind.INITCODE,
id="RETURNCONTRACT/STOP",
),
pytest.param(
returncontract_code_section,
return_sub_container,
ContainerKind.INITCODE,
id="RETURNCONTRACT/RETURN",
),
pytest.param(
eofcreate_code_section,
revert_sub_container,
ContainerKind.RUNTIME,
id="EOFCREATE/REVERT",
),
pytest.param(
returncontract_code_section,
revert_sub_container,
ContainerKind.INITCODE,
id="RETURNCONTRACT/REVERT",
),
],
)
def test_container_combos_non_first_code_sections_valid(
eof_test: EOFTestFiller,
code_section: Section,
first_sub_container: Container,
container_kind: ContainerKind,
):
"""Test valid subcontainer reference / opcode combos in a non-first code section"""
eof_test(
data=Container(
sections=[Section.Code(Op.JUMPF[i]) for i in range(1, 1024)]
+ [code_section, first_sub_container],
kind=container_kind,
),
)


@pytest.mark.parametrize(
"code_section,first_sub_container,container_kind",
[
Expand Down

0 comments on commit 9b070ad

Please sign in to comment.