Skip to content

Commit

Permalink
new(tests): Add test for invalid subcontainer kinds on a deeper nesti…
Browse files Browse the repository at this point in the history
…ng level
  • Loading branch information
gumb0 committed Jul 9, 2024
1 parent 4dcb31d commit cb3d307
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,60 @@ def test_container_combos_invalid(
)


@pytest.mark.parametrize(
"code_section,first_sub_container,container_kind",
[
pytest.param(
eofcreate_code_section,
stop_sub_container,
ContainerKind.RUNTIME,
id="EOFCREATE/STOP",
),
pytest.param(
eofcreate_code_section,
return_sub_container,
ContainerKind.RUNTIME,
id="EOFCREATE/RETURN",
),
pytest.param(
returncontract_code_section,
returncontract_sub_container,
ContainerKind.INITCODE,
id="RETURNCONTRACT/RETURNCONTRACT",
),
],
)
def test_container_combos_deeply_nested_invalid(
eof_test: EOFTestFiller,
code_section: Section,
first_sub_container: Container,
container_kind: ContainerKind,
):
"""Test invalid subcontainer reference / opcode combos on a deep container nesting level"""
invalid_container = Container(
sections=[
code_section,
first_sub_container,
],
kind=container_kind,
)

container = invalid_container
while len(container) < 0x6000:
container = Container(
sections=[
eofcreate_code_section,
Section.Container(container=container.copy()),
],
kind=ContainerKind.INITCODE,
)

eof_test(
data=container,
expect_exception=EOFException.INCOMPATIBLE_CONTAINER_KIND,
)


def test_container_both_kinds_same_sub(eof_test: EOFTestFiller):
"""Test subcontainer conflicts (both EOFCREATE and RETURNCONTRACT Reference)"""
eof_test(
Expand Down

0 comments on commit cb3d307

Please sign in to comment.