Skip to content

Commit

Permalink
new(tests): Add test for CALLF runtime stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jul 11, 2024
1 parent ba60080 commit 8ce811b
Showing 1 changed file with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,61 @@ def test_callf_stack_size_1024(
),
container_post=Account(storage={slot_code_worked: value_code_worked}),
)


def test_callf_with_inputs_stack_size_1024(
eof_state_test: EOFStateTestFiller,
):
"""Test stack reaching 1024 items in called function with inputs"""
eof_state_test(
data=Container(
sections=[
Section.Code(
code=Op.PUSH0 * 1023
+ Op.CALLF[1]
+ Op.POP * 1023
+ Op.SSTORE(slot_code_worked, value_code_worked)
+ Op.RETURN(0, 0),
max_stack_height=1023,
),
Section.Code(
Op.PUSH0 + Op.POP + Op.RETF, code_inputs=3, code_outputs=3, max_stack_height=4
),
],
),
container_post=Account(storage={slot_code_worked: value_code_worked}),
)


def test_callf_stack_overflow(
eof_state_test: EOFStateTestFiller,
):
"""Test stack overflowing 1024 items in called function"""
eof_state_test(
data=Container(
sections=[
Section.Code(
code=Op.PUSH0 * 1023
+ Op.CALLF[1]
+ Op.POP * 1023
+ Op.SSTORE(slot_code_worked, value_code_worked)
+ Op.RETURN(0, 0),
max_stack_height=1023,
),
Section.Code(
Op.PUSH0 + Op.CALLF[2] + Op.POP + Op.RETF,
code_inputs=0,
code_outputs=0,
max_stack_height=1,
),
Section.Code(
Op.PUSH0 + Op.POP + Op.RETF,
code_inputs=0,
code_outputs=0,
max_stack_height=1,
),
],
),
# TODO expect execution exceptional abort?
validity_error=EOFException.UNDEFINED_EXCEPTION,
)

0 comments on commit 8ce811b

Please sign in to comment.