diff options
author | chriseth <chris@ethereum.org> | 2016-08-17 22:44:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-17 22:44:15 +0800 |
commit | b2507e9f105ab701c417f8f2d125edf8f3022698 (patch) | |
tree | e67c6047c68d8e89e218fcb5dec1ef394aa4b828 /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | d6579a0a5f99425eae95329b77e07ea072122924 (diff) | |
parent | 774bb8ab3baa9d7b5e6368dcd0f887b13ff26ae8 (diff) | |
download | dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.gz dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.tar.zst dexon-solidity-b2507e9f105ab701c417f8f2d125edf8f3022698.zip |
Merge pull request #839 from chriseth/checkcode
BREAKING: Make function calls throw if target does not have code.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index f20ea2cb..4e6f68b0 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -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() } |