diff --git a/test/unittests/eof_validation_test.cpp b/test/unittests/eof_validation_test.cpp index ef3f686037..2576573428 100644 --- a/test/unittests/eof_validation_test.cpp +++ b/test/unittests/eof_validation_test.cpp @@ -1213,3 +1213,59 @@ TEST_F(eof_validation, max_nested_containers) add_test_case(code, EOFValidationError::success); } + +TEST_F(eof_validation, toplevel_container_stop) +{ + const auto code = bytecode{OP_STOP}; + const auto container = eof_bytecode(code, 0); + + add_test_case(container, EOFValidationError::success); +} + +TEST_F(eof_validation, eofcreate_initcontainer_stop) +{ + const auto init_code = bytecode{OP_STOP}; + const auto init_container = eof_bytecode(init_code, 0); + const auto factory_code = eofcreate() + OP_STOP; + const bytecode factory_container = eof_bytecode(factory_code, 4).container(init_container); + + add_test_case(factory_container, EOFValidationError::incompatible_container_kind); +} + +TEST_F(eof_validation, toplevel_container_return) +{ + const auto code = ret(0, 0); + const bytecode container = eof_bytecode(code, 2); + + add_test_case(container, EOFValidationError::success); +} + +TEST_F(eof_validation, eofcreate_initcontainer_return) +{ + const auto init_code = bytecode{ret(0, 0)}; + const auto init_container = eof_bytecode(init_code, 2); + const auto factory_code = eofcreate() + OP_STOP; + const bytecode factory_container = eof_bytecode(factory_code, 4).container(init_container); + + add_test_case(factory_container, EOFValidationError::incompatible_container_kind); +} + +TEST_F(eof_validation, toplevel_container_returncontract) +{ + const auto code = returncontract(0, 0, 0); + const auto container = eof_bytecode(code, 2).container(eof_bytecode(OP_INVALID)); + + add_test_case(container, EOFValidationError::success); +} + +TEST_F(eof_validation, eofcreate_runtime_container_returncontract) +{ + const auto runtime_container = + eof_bytecode(returncontract(0, 0, 0), 2).container(eof_bytecode(OP_INVALID)); + const auto init_container = + eof_bytecode(returncontract(0, 0, 0), 2).container(runtime_container); + const auto factory_code = eofcreate() + OP_STOP; + const bytecode factory_container = eof_bytecode(factory_code, 4).container(init_container); + + add_test_case(factory_container, EOFValidationError::incompatible_container_kind); +}