Skip to content

eof example with prameters #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions tests/prague/eip3540_eof_v1/test_eof_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ethereum_test_tools import EOFTestFiller
from ethereum_test_tools import Opcodes as Op
from ethereum_test_tools.eof.v1 import AutoSection, Container, Section
from ethereum_test_tools.eof.v1 import AutoSection, BytesConvertible, Container, Section
from ethereum_test_tools.eof.v1.constants import NON_RETURNING_SECTION

from .spec import EOF_FORK_NAME
Expand Down Expand Up @@ -63,8 +63,8 @@ def test_eof_example(eof_test: EOFTestFiller):

# This will construct a valid EOF container with these bytes
assert bytes(eof_code) == bytes.fromhex(
"ef0001010010020004000500060008000204000000008000010100000100010003020300035fe300010050"
"e3000250e43080e300035050e480e4"
"ef0001010010020004000500060008000204000100008000010100000100010003020300035fe300010050"
"e3000250e43080e300035050e480e4ef"
)

eof_test(
Expand Down Expand Up @@ -125,3 +125,38 @@ def test_eof_example_custom_fields(eof_test: EOFTestFiller):
data=eof_code,
expect_exception=eof_code.validity_error,
)


@pytest.mark.parametrize(
"data_section_bytes",
("0x01", "0xef"),
)
@pytest.mark.parametrize(
"code_section_code",
(Op.PUSH1(10) + Op.STOP, Op.PUSH1(14) + Op.STOP),
)
def test_eof_example_parameters(
eof_test: EOFTestFiller,
data_section_bytes: BytesConvertible,
code_section_code: BytesConvertible,
):
"""
Example of python EOF classes
"""
eof_code = Container(
name="parametrized_eof_example",
sections=[
Section.Code(
code=code_section_code,
code_inputs=0,
code_outputs=NON_RETURNING_SECTION,
max_stack_height=1,
),
Section.Data(data_section_bytes),
],
)

eof_test(
data=eof_code,
expect_exception=eof_code.validity_error,
)