Skip to content

Commit

Permalink
Merge pull request #5971 from ethereum/overloadedEvents
Browse files Browse the repository at this point in the history
More tests for overloaded events.
  • Loading branch information
chriseth authored Feb 12, 2019
2 parents f0f3498 + 091bbdb commit 9ab72f0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/libsolidity/SolidityEndToEndTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3746,17 +3746,22 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
event Deposit();
event Deposit(address _addr);
event Deposit(address _addr, uint _amount);
event Deposit(address _addr, bool _flag);
function deposit() public returns (uint) {
emit Deposit();
return 1;
}
function deposit(address _addr) public returns (uint) {
emit Deposit(_addr);
return 1;
return 2;
}
function deposit(address _addr, uint _amount) public returns (uint) {
emit Deposit(_addr, _amount);
return 1;
return 3;
}
function deposit(address _addr, bool _flag) public returns (uint) {
emit Deposit(_addr, _flag);
return 4;
}
}
)";
Expand All @@ -3770,19 +3775,26 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));

ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(1)));
ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(2)));
BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address)")));

ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(1)));
ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(3)));
BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress, 100));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,uint256)")));

ABI_CHECK(callContractFunction("deposit(address,bool)", c_loggedAddress, false), encodeArgs(u256(4)));
BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress, false));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,bool)")));
}

BOOST_AUTO_TEST_CASE(events_with_same_name_inherited_emit)
Expand Down

0 comments on commit 9ab72f0

Please sign in to comment.