mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #839 from chriseth/checkcode
BREAKING: Make function calls throw if target does not have code.
This commit is contained in:
@@ -7049,6 +7049,32 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input)
|
||||
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract D { function g(); }
|
||||
contract C {
|
||||
D d = D(0x1212);
|
||||
function f() returns (uint) {
|
||||
d.g();
|
||||
return 7;
|
||||
}
|
||||
function g() returns (uint) {
|
||||
d.g.gas(200)();
|
||||
return 7;
|
||||
}
|
||||
function h() returns (uint) {
|
||||
d.call(); // this does not throw (low-level)
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
BOOST_CHECK(callContractFunction("f()") == encodeArgs());
|
||||
BOOST_CHECK(callContractFunction("g()") == encodeArgs());
|
||||
BOOST_CHECK(callContractFunction("h()") == encodeArgs(u256(7)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user