aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2015-01-30 08:05:17 +0800
committerGav Wood <i@gavwood.com>2015-01-30 08:05:17 +0800
commitb1043c8651f16595ac95bf34aefd9f1bb8b3885d (patch)
tree0ec06a2a93e8d4d892f8fc4dd92ffa015da6de9d
parenta55a99a2b0ce860134a4e30b2f27a20489f37f0a (diff)
parent7925610ab4f6b2110526bc4accb30ee971d8fe5f (diff)
downloaddexon-solidity-b1043c8651f16595ac95bf34aefd9f1bb8b3885d.tar.gz
dexon-solidity-b1043c8651f16595ac95bf34aefd9f1bb8b3885d.tar.zst
dexon-solidity-b1043c8651f16595ac95bf34aefd9f1bb8b3885d.zip
Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop
Conflicts: test/SolidityEndToEndTest.cpp test/SolidityNameAndTypeResolution.cpp test/SolidityParser.cpp
-rw-r--r--SolidityEndToEndTest.cpp51
-rw-r--r--SolidityNameAndTypeResolution.cpp43
-rw-r--r--SolidityParser.cpp27
-rw-r--r--solidityExecutionFramework.h1
4 files changed, 121 insertions, 1 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 576e0f91..da7f70d1 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -1986,6 +1986,57 @@ BOOST_AUTO_TEST_CASE(inherited_fallback_function)
BOOST_CHECK(callContractFunction("getData()") == encodeArgs(1));
}
+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, hash32(msg.sender), _id);
+ } else
+ Deposit(hash32(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, hash32(_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/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index d081916c..13d3a5d2 100644
--- a/SolidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -728,6 +728,49 @@ BOOST_AUTO_TEST_CASE(fallback_function_inheritance)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
+BOOST_AUTO_TEST_CASE(event)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint indexed a, string3 indexed s, bool indexed b);
+ function f() { e(2, "abc", true); }
+ })";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(event_too_many_indexed)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint indexed a, string3 indexed b, bool indexed c, uint indexed d);
+ function f() { e(2, "abc", true); }
+ })";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(event_call)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint a, string3 indexed s, bool indexed b);
+ function f() { e(2, "abc", true); }
+ })";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(event_inheritance)
+{
+ char const* text = R"(
+ contract base {
+ event e(uint a, string3 indexed s, bool indexed b);
+ }
+ contract c is base {
+ function f() { e(2, "abc", true); }
+ })";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/SolidityParser.cpp b/SolidityParser.cpp
index 0059ccf7..4adee9c6 100644
--- a/SolidityParser.cpp
+++ b/SolidityParser.cpp
@@ -594,6 +594,33 @@ BOOST_AUTO_TEST_CASE(fallback_function)
BOOST_CHECK_NO_THROW(parseText(text));
}
+BOOST_AUTO_TEST_CASE(event)
+{
+ char const* text = R"(
+ contract c {
+ event e();
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(event_arguments)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint a, string32 s);
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
+BOOST_AUTO_TEST_CASE(event_arguments_indexed)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint a, string32 indexed s, bool indexed b);
+ })";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
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;