Skip to content
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

fix(tests): EOF - EIP-3540: update validation tests for recent spec #558

Merged
merged 1 commit into from
May 28, 2024
Merged
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
47 changes: 26 additions & 21 deletions tests/prague/eip7692_eof_v1/eip3540_eof_v1/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
MAX_CODE_INPUTS,
MAX_CODE_OUTPUTS,
MAX_OPERAND_STACK_HEIGHT,
NON_RETURNING_SECTION,
)
from ethereum_test_tools.exceptions import EOFException
from ethereum_test_tools.vm.opcode import Opcodes as Op
Expand All @@ -19,10 +20,31 @@
Container(
name="single_code_single_data_section",
sections=[
Section.Code(code=Op.ADDRESS + Op.POP + Op.STOP, code_outputs=128, max_stack_height=1),
Section.Code(
code=Op.ADDRESS + Op.POP + Op.STOP,
code_outputs=NON_RETURNING_SECTION,
max_stack_height=1,
),
Section.Data(data="0xef"),
],
),
Container(
# EOF allows truncated data section
name="no_data_section_contents",
sections=[
Section.Code(Op.STOP, code_outputs=NON_RETURNING_SECTION),
Section.Data(data="0x", custom_size=1),
],
code="ef0001 010004 0200010001 040001 00 00800000 00",
),
Container(
# EOF allows truncated data section
name="data_section_contents_incomplete",
sections=[
Section.Code(Op.STOP, code_outputs=NON_RETURNING_SECTION),
Section.Data(data="0xAABBCC", custom_size=4),
],
),
# TODO this is the only valid code I managed to produce
# somehow if code is 00 byte it gets rejected
# also if max_stack_height and code_outputs are not set it gets rejected
Expand Down Expand Up @@ -300,28 +322,11 @@
name="no_section_terminator_4a",
header_terminator=bytes(),
sections=[
Section.Code(Op.STOP),
Section.Code(Op.STOP, code_outputs=NON_RETURNING_SECTION),
Section.Data(data="0xAABBCCDD"),
],
# TODO the exception must be about terminator
validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
),
Container(
name="no_data_section_contents",
sections=[
Section.Code(Op.STOP),
Section.Data(data="0x", custom_size=1),
],
# TODO: maybe it should detect that it is the data body that is wrong
validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
),
Container(
name="data_section_contents_incomplete",
sections=[
Section.Code(Op.STOP),
Section.Data(data="0xAABBCC", custom_size=4),
],
validity_error=EOFException.INVALID_SECTION_BODIES_SIZE,
# TODO: The error of this validation can be random.
validity_error=EOFException.INVALID_FIRST_SECTION_TYPE,
),
Container(
name="trailing_bytes_after_data_section",
Expand Down