aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-10-18 22:05:16 +0800
committerYoichi Hirai <i@yoichihirai.com>2017-01-23 22:25:13 +0800
commit0e85e35a7f5f8129672ac02b38771749f4e5d456 (patch)
tree4dc869b4a5ef334fb3ae10ab40a2b4975554f5eb
parent08015590f23957153e12f06a2bcba6e9246733bc (diff)
downloaddexon-solidity-0e85e35a7f5f8129672ac02b38771749f4e5d456.tar.gz
dexon-solidity-0e85e35a7f5f8129672ac02b38771749f4e5d456.tar.zst
dexon-solidity-0e85e35a7f5f8129672ac02b38771749f4e5d456.zip
test: Add an end-to-end test about multiple events of the same name
See #1215
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 19161831..2411e7ff 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2792,6 +2792,47 @@ BOOST_AUTO_TEST_CASE(event_access_through_base_name)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("x()")));
}
+BOOST_AUTO_TEST_CASE(events_with_same_name)
+{
+ char const* sourceCode = R"(
+ contract ClientReceipt {
+ event Deposit;
+ event Deposit(address _addr);
+ event Deposit(address _addr, uint _amount);
+ function deposit() {
+ Deposit();
+ }
+ function deposit(address _addr) {
+ Deposit(_addr);
+ }
+ function deposit(address _addr, uint _amount) {
+ Deposit(_addr, _amount);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ callContractFunction("deposit()");
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK(m_logs[0].data.empty());
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));
+
+ callContractFunction("deposit(0xabcdeabcdeabcdeabcde)");
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 2);
+ BOOST_CHECK_EQUAL(m_logs[1].address, m_contractAddress);
+ BOOST_CHECK(m_logs[1].data == encodeArgs(0));
+ BOOST_REQUIRE_EQUAL(m_logs[1].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[1].topics[0], dev::keccak256(string("Deposit(address)")));
+
+ callContractFunction("deposit(0xabcdeabcdeabcdeabcde, 100)");
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 3);
+ BOOST_CHECK_EQUAL(m_logs[2].address, m_contractAddress);
+ BOOST_CHECK(m_logs[2].data == encodeArgs(0,100));
+ BOOST_REQUIRE_EQUAL(m_logs[2].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[2].topics[0], dev::keccak256(string("Deposit(address,uint256)")));
+}
+
BOOST_AUTO_TEST_CASE(event_anonymous)
{
char const* sourceCode = R"(