aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-29 23:42:59 +0800
committerChristian <c@ethdev.com>2015-01-30 04:33:46 +0800
commit99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01 (patch)
treefbecb8845f4b384b8dda03cbf536e569a8c7a95f
parenta86a3a245219cc3d9c4e5fc146afd61f3f3e7b97 (diff)
downloaddexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.tar
dexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.tar.gz
dexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.tar.bz2
dexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.tar.lz
dexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.tar.xz
dexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.tar.zst
dexon-solidity-99a8f58ee3091ef0ff2389f0b7ad8f1e1fe2df01.zip
Code generation for events.
-rw-r--r--SolidityEndToEndTest.cpp51
-rw-r--r--solidityExecutionFramework.h1
2 files changed, 51 insertions, 1 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index f2976707..0df2d914 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -1955,6 +1955,57 @@ BOOST_AUTO_TEST_CASE(super_in_constructor)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(1 | 2 | 4 | 8));
}
+BOOST_AUTO_TEST_CASE(event)
+{
+ char const* sourceCode = R"(
+ contract ClientReceipt {
+ event Deposit(address indexed _from, hash indexed _id, uint _value);
+ function deposit(hash _id, bool _manually) {
+ if (_manually) {
+ hash s = 0x50cb9fe53daa9737b786ab3646f04d0150dc50ef4e75f59509d83667ad5adb20;
+ log3(msg.value, s, hash(msg.sender), _id);
+ } else
+ Deposit(msg.sender, _id, msg.value);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ u256 value(18);
+ u256 id(0x1234);
+ for (bool manually: {true, false})
+ {
+ callContractFunctionWithValue("deposit(hash256,bool)", value, id, manually);
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(value)));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 3);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,hash256,uint256)")));
+ BOOST_CHECK_EQUAL(m_logs[0].topics[1], h256(m_sender));
+ BOOST_CHECK_EQUAL(m_logs[0].topics[2], h256(id));
+ }
+}
+
+BOOST_AUTO_TEST_CASE(event_lots_of_data)
+{
+ char const* sourceCode = R"(
+ contract ClientReceipt {
+ event Deposit(address _from, hash _id, uint _value, bool _flag);
+ function deposit(hash _id) {
+ Deposit(msg.sender, _id, msg.value, true);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ u256 value(18);
+ u256 id(0x1234);
+ callContractFunctionWithValue("deposit(hash256)", value, id);
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK(m_logs[0].data == encodeArgs(m_sender, id, value, true));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,hash256,uint256,bool)")));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/solidityExecutionFramework.h b/solidityExecutionFramework.h
index 7dad9ad4..5a693536 100644
--- a/solidityExecutionFramework.h
+++ b/solidityExecutionFramework.h
@@ -67,7 +67,6 @@ public:
bytes const& callContractFunctionWithValue(std::string _sig, u256 const& _value,
Args const&... _arguments)
{
-
FixedHash<4> hash(dev::sha3(_sig));
sendMessage(hash.asBytes() + encodeArgs(_arguments...), false, _value);
return m_output;