Skip to content

Commit 821a69f

Browse files
committed
Test case: initcode-mode not being EOF-validated
1 parent 3599674 commit 821a69f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/unittests/eof_validation_test.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -1142,3 +1142,21 @@ 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+
}

0 commit comments

Comments
 (0)