Skip to content

Commit 73c2d33

Browse files
committed
Test case: initcode-mode not being EOF-validated
1 parent 67cbffe commit 73c2d33

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/unittests/eof_validation_test.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -1142,3 +1142,27 @@ TEST_F(eof_validation, EOF1_returncontract_invalid)
11421142
.container(embedded),
11431143
EOFValidationError::unreachable_instructions);
11441144
}
1145+
1146+
TEST_F(eof_validation, EOF1_eofcreate_returncontract_return_mix_valid)
1147+
{
1148+
// This test ensures that we _do not_ have a validation rule preventing EOFCREATE,
1149+
// RETURNCONTRACT and RETURN mixing.
1150+
const auto embedded = eof_bytecode(bytecode{OP_INVALID});
1151+
1152+
// This contains both RETURNCONTRACT and RETURN, as well as references same
1153+
// container from both EOFCREATE and RETURNCONTRACT
1154+
const auto mixing_initcode =
1155+
eofcreate().container(0) + rjumpi(6, 1) + returncontract(0, 0, 0) + ret_top();
1156+
1157+
const auto mixing_initcontainer = eof_bytecode(mixing_initcode, 4).container(embedded);
1158+
1159+
// This top level container mixes all combinations of EOFCREATE/RETURNCONTRACT/RETURN.
1160+
add_test_case(eof_bytecode(mixing_initcode, 4).container(mixing_initcontainer),
1161+
EOFValidationError::success);
1162+
}
1163+
1164+
TEST_F(eof_validation, EOF1_unreferenced_subcontainer_valid)
1165+
{
1166+
const auto embedded = eof_bytecode(bytecode{OP_INVALID});
1167+
add_test_case(eof_bytecode(OP_STOP).container(embedded), EOFValidationError::success);
1168+
}

0 commit comments

Comments
 (0)