From cb3d3071057e304cbd16f4d4c4b93d7c1a3fb331 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Tue, 9 Jul 2024 12:28:10 +0200 Subject: [PATCH] new(tests): Add test for invalid subcontainer kinds on a deeper nesting level --- .../test_subcontainer_validation.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py b/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py index b68896630f..e288073a10 100644 --- a/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py +++ b/tests/prague/eip7692_eof_v1/eip7620_eof_create/test_subcontainer_validation.py @@ -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(