Skip to content

Commit 54526b8

Browse files
authored
new(tests): tests for JUMPF invalid section index (ethereum#1112)
1 parent f10dc9d commit 54526b8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""EOF validation tests for JUMPF instruction."""
2+
3+
import pytest
4+
5+
from ethereum_test_tools import EOFException, EOFTestFiller
6+
from ethereum_test_tools.eof.v1 import Container, Section
7+
from ethereum_test_tools.vm.opcode import Opcodes as Op
8+
9+
from .. import EOF_FORK_NAME
10+
11+
REFERENCE_SPEC_GIT_PATH = "EIPS/eip-6206.md"
12+
REFERENCE_SPEC_VERSION = "2f365ea0cd58faa6e26013ea77ce6d538175f7d0"
13+
14+
pytestmark = pytest.mark.valid_from(EOF_FORK_NAME)
15+
16+
17+
@pytest.mark.parametrize(
18+
"container",
19+
[
20+
Container(
21+
name="jumpf1",
22+
sections=[
23+
Section.Code(
24+
Op.JUMPF[1],
25+
)
26+
],
27+
),
28+
Container(
29+
name="jumpf2",
30+
sections=[
31+
Section.Code(
32+
Op.JUMPF[2],
33+
),
34+
Section.Code(
35+
Op.STOP,
36+
),
37+
],
38+
),
39+
Container(
40+
name="jumpf1_jumpf2",
41+
sections=[
42+
Section.Code(
43+
Op.JUMPF[1],
44+
),
45+
Section.Code(
46+
Op.JUMPF[2],
47+
),
48+
],
49+
),
50+
],
51+
ids=lambda container: container.name,
52+
)
53+
def test_invalid_code_section_index(
54+
eof_test: EOFTestFiller,
55+
container: Container,
56+
):
57+
"""Test cases for JUMPF instructions with invalid target code section index."""
58+
eof_test(data=container, expect_exception=EOFException.INVALID_CODE_SECTION_INDEX)

0 commit comments

Comments
 (0)