Browse Source

one more test to test the call of non-existed function

Conflicts:
	test/libsolidity/SolidityEndToEndTest.cpp
cl-refactor
Liana Husikyan 10 years ago
parent
commit
77e1d116ca
  1. 2
      libsolidity/ExpressionCompiler.cpp
  2. 28
      test/libsolidity/SolidityEndToEndTest.cpp

2
libsolidity/ExpressionCompiler.cpp

@ -1106,7 +1106,7 @@ void ExpressionCompiler::appendExternalFunctionCall(
//Propagate error condition (if CALL pushes 0 on stack). //Propagate error condition (if CALL pushes 0 on stack).
m_context << eth::Instruction::ISZERO; m_context << eth::Instruction::ISZERO;
auto tag = m_context.appendConditionalJumpTo(m_context.errorTag()); m_context.appendConditionalJumpTo(m_context.errorTag());
if (_functionType.valueSet()) if (_functionType.valueSet())
m_context << eth::Instruction::POP; m_context << eth::Instruction::POP;

28
test/libsolidity/SolidityEndToEndTest.cpp

@ -4111,7 +4111,7 @@ BOOST_AUTO_TEST_CASE(struct_delete_struct_in_mapping)
BOOST_CHECK(callContractFunction("deleteIt()") == encodeArgs(0)); BOOST_CHECK(callContractFunction("deleteIt()") == encodeArgs(0));
} }
BOOST_AUTO_TEST_CASE(evm_exceptions) BOOST_AUTO_TEST_CASE(evm_exceptions_out_of_band_access)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract A { contract A {
@ -4135,6 +4135,32 @@ BOOST_AUTO_TEST_CASE(evm_exceptions)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(false)); BOOST_CHECK(callContractFunction("test()") == encodeArgs(false));
} }
BOOST_AUTO_TEST_CASE(evm_exceptions_when_calling_non_existing_function)
{
char const* sourceCode = R"(
contract A {
uint public test = 0;
function badFunction() returns (uint)
{
this.call("123");
test = 1;
return 2;
}
function testIt() returns (bool)
{
this.badFunction();
test = 2;
return true;
}
}
)";
compileAndRun(sourceCode, 0, "A");
BOOST_CHECK(callContractFunction("test()") == encodeArgs(0));
BOOST_CHECK(callContractFunction("testIt()") == encodeArgs());
BOOST_CHECK(callContractFunction("test()") == encodeArgs(0));
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

Loading…
Cancel
Save