From b086cba505263113bf400e5315c3afddea0c53e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 26 Aug 2024 13:41:47 +0200 Subject: [PATCH] new(tests): migrate EOF "embedded container" tests Migrate EOFTests/efValidation/EOF1_embedded_container_.json. --- converted-ethereum-tests.txt | 1 + .../test_subcontainer_validation.py | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/converted-ethereum-tests.txt b/converted-ethereum-tests.txt index 1cc2ed0111..81d3d49a27 100644 --- a/converted-ethereum-tests.txt +++ b/converted-ethereum-tests.txt @@ -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 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 1b5e586ca4..00b785778b 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 @@ -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=[ @@ -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=[ @@ -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):