aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-16 00:02:09 +0800
committerchriseth <c@ethdev.com>2015-05-16 00:02:09 +0800
commit563f9098b233f10b4f3d5c89d0020084c7d6889b (patch)
treed23dc645f7a9b402da7dc2e292bd9105873e0780 /libsolidity
parent5f8a5f672d64a626f59f3f190ab835773faa8283 (diff)
downloaddexon-solidity-563f9098b233f10b4f3d5c89d0020084c7d6889b.tar.gz
dexon-solidity-563f9098b233f10b4f3d5c89d0020084c7d6889b.tar.zst
dexon-solidity-563f9098b233f10b4f3d5c89d0020084c7d6889b.zip
Bare callcode for addresses and contracts.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index ed5f1acd..6713382f 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -2558,6 +2558,37 @@ BOOST_AUTO_TEST_CASE(generic_call)
BOOST_CHECK_EQUAL(m_state.balance(m_contractAddress), 50 - 2);
}
+BOOST_AUTO_TEST_CASE(generic_callcode)
+{
+ char const* sourceCode = R"**(
+ contract receiver {
+ uint public received;
+ function receive(uint256 x) { received = x; }
+ }
+ contract sender {
+ uint public received;
+ function doSend(address rec) returns (uint d)
+ {
+ bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
+ rec.callcode.value(2)(signature, 23);
+ return receiver(rec).received();
+ }
+ }
+ )**";
+ compileAndRun(sourceCode, 0, "receiver");
+ u160 const c_receiverAddress = m_contractAddress;
+ compileAndRun(sourceCode, 50, "sender");
+ u160 const c_senderAddress = m_contractAddress;
+ BOOST_CHECK(callContractFunction("doSend(address)", c_receiverAddress) == encodeArgs(0));
+ BOOST_CHECK(callContractFunction("received()") == encodeArgs(23));
+ m_contractAddress = c_receiverAddress;
+ BOOST_CHECK(callContractFunction("received()") == encodeArgs(0));
+ BOOST_CHECK(m_state.storage(c_receiverAddress).empty());
+ BOOST_CHECK(!m_state.storage(c_senderAddress).empty());
+ BOOST_CHECK_EQUAL(m_state.balance(c_receiverAddress), 0);
+ BOOST_CHECK_EQUAL(m_state.balance(c_senderAddress), 50);
+}
+
BOOST_AUTO_TEST_CASE(store_bytes)
{
// this test just checks that the copy loop does not mess up the stack