diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-08-01 17:43:06 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-08-02 03:50:03 +0800 |
commit | b3061225bcd1dd03cb1809b6193857d69cd7768f (patch) | |
tree | 63cb76a25e6e3eb5cbd63efd9c49be471f6585ef /test/libsolidity | |
parent | 3aacfc7e3569b27ca97dce41d886bbc3043546e0 (diff) | |
download | dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.tar dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.tar.gz dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.tar.bz2 dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.tar.lz dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.tar.xz dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.tar.zst dexon-solidity-b3061225bcd1dd03cb1809b6193857d69cd7768f.zip |
.delegatecall() should always return a boolean of execution status
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 2c9dfad9..60a0607a 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9897,6 +9897,42 @@ BOOST_AUTO_TEST_CASE(inlineasm_empty_let) BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0), u256(0))); } +BOOST_AUTO_TEST_CASE(delegatecall_return_value) +{ + char const* sourceCode = R"DELIMITER( + contract C { + uint value; + function set(uint _value) external { + value = _value; + } + function get() external constant returns (uint) { + return value; + } + function get_delegated() external constant returns (bool) { + return this.delegatecall(bytes4(sha3("get()"))); + } + function assert0() external constant { + assert(value == 0); + } + function assert0_delegated() external constant returns (bool) { + return this.delegatecall(bytes4(sha3("assert0()"))); + } + } + )DELIMITER"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("get()") == encodeArgs(u256(0))); + BOOST_CHECK(callContractFunction("assert0_delegated()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("get_delegated()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("set(uint256)", u256(1)) == encodeArgs()); + BOOST_CHECK(callContractFunction("get()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("assert0_delegated()") == encodeArgs(u256(0))); + BOOST_CHECK(callContractFunction("get_delegated()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("set(uint256)", u256(42)) == encodeArgs()); + BOOST_CHECK(callContractFunction("get()") == encodeArgs(u256(42))); + BOOST_CHECK(callContractFunction("assert0_delegated()") == encodeArgs(u256(0))); + BOOST_CHECK(callContractFunction("get_delegated()") == encodeArgs(u256(1))); +} + BOOST_AUTO_TEST_SUITE_END() } |