Skip to content

Commit d27275d

Browse files
authored
new(tests): extend RJUMP over unreachable code (#1267)
Parametrize and add more test cases for invalid EOF code with RJUMP over an unreachable instruction.
1 parent 648eba6 commit d27275d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

converted-ethereum-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ EOFTests/efStack/forwards_rjump_.json
2424
EOFTests/efStack/forwards_rjump_variable_stack_.json
2525
EOFTests/efStack/forwards_rjumpi_.json
2626
EOFTests/efStack/forwards_rjumpi_variable_stack_.json
27+
EOFTests/efStack/unreachable_instructions_.json
2728
EOFTests/efValidation/callf_into_nonreturning_.json
2829
EOFTests/efValidation/dataloadn_.json
2930
EOFTests/efValidation/EOF1_embedded_container_.json

tests/osaka/eip7692_eof_v1/eip4200_relative_jumps/test_rjump.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,11 +1017,23 @@ def test_rjump_into_returncontract(
10171017
)
10181018

10191019

1020+
@pytest.mark.parametrize(
1021+
"unreachable_op",
1022+
[Op.STOP, Op.PUSH1[0], Op.PUSH2[0], Op.RJUMP[-3], Op.RJUMP[0], Op.INVALID],
1023+
)
1024+
@pytest.mark.parametrize(
1025+
"terminating_op",
1026+
[Op.STOP, Op.RJUMP[-3], Op.INVALID],
1027+
)
10201028
def test_rjump_unreachable_code(
10211029
eof_test: EOFTestFiller,
1030+
unreachable_op: Op,
1031+
terminating_op: Op,
10221032
):
10231033
"""EOF code containing instructions skipped by RJUMP."""
1024-
container = Container.Code(code=(Op.RJUMP[len(Op.STOP)] + Op.STOP + Op.STOP))
1034+
container = Container.Code(
1035+
code=(Op.RJUMP[len(unreachable_op)] + unreachable_op + terminating_op)
1036+
)
10251037
eof_test(
10261038
container=container,
10271039
expect_exception=EOFException.UNREACHABLE_INSTRUCTIONS,

tests/osaka/eip7692_eof_v1/eof_tracker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
- [ ] Check all terminating opcodes (ethereum/tests: ./src/EOFTestsFiller/efExample/validInvalidFiller.yml src/EOFTestsFiller/EIP5450/validInvalidFiller.yml)
174174
- [ ] Code section not terminating (executing beyond section end) (ethereum/tests: ./src/EOFTestsFiller/efExample/validInvalidFiller.yml src/EOFTestsFiller/EIP5450/validInvalidFiller.yml src/EOFTestsFiller/efStack/no_terminating_instruction_Copier.json)
175175
- [ ] Code section ending with NOP (not terminating) (src/EOFTestsFiller/EIP5450/validInvalidFiller.yml)
176-
- [ ] Check that unreachable code is invalid after all terminating instructions (ethereum/tests: src/EOFTestsFiller/EIP5450/validInvalidFiller.yml src/EOFTestsFiller/efStack/unreachable_instructions_Copier.json)
176+
- [ ] Check that unreachable code is invalid after all terminating instructions (ethereum/tests: src/EOFTestsFiller/EIP5450/validInvalidFiller.yml)
177177

178178
#### Jumps
179179

0 commit comments

Comments
 (0)