aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-07 22:40:54 +0800
committerchriseth <c@ethdev.com>2015-10-07 22:40:54 +0800
commitb6ddde9372c897c1eafc24ee16e3aa6aeec3f2f6 (patch)
treea4f46b14f7290c78b47c46ea152f4a0305e348dc
parent5053e153ece086ce3b5e4d9a3324a526306a1579 (diff)
downloaddexon-solidity-b6ddde9372c897c1eafc24ee16e3aa6aeec3f2f6.tar.gz
dexon-solidity-b6ddde9372c897c1eafc24ee16e3aa6aeec3f2f6.tar.zst
dexon-solidity-b6ddde9372c897c1eafc24ee16e3aa6aeec3f2f6.zip
Allow four indexed arguments for anynomous events.
-rw-r--r--libsolidity/TypeChecker.cpp4
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp10
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp18
3 files changed, 27 insertions, 5 deletions
diff --git a/libsolidity/TypeChecker.cpp b/libsolidity/TypeChecker.cpp
index fe6fb970..2afa5649 100644
--- a/libsolidity/TypeChecker.cpp
+++ b/libsolidity/TypeChecker.cpp
@@ -554,7 +554,9 @@ bool TypeChecker::visit(EventDefinition const& _eventDef)
{
if (var->isIndexed())
numIndexed++;
- if (numIndexed > 3)
+ if (_eventDef.isAnonymous() && numIndexed > 4)
+ typeError(_eventDef, "More than 4 indexed arguments for anonymous event.");
+ else if (!_eventDef.isAnonymous() && numIndexed > 3)
typeError(_eventDef, "More than 3 indexed arguments for event.");
if (!type(*var)->canLiveOutsideStorage())
typeError(*var, "Type is required to live outside storage.");
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index a17a3be5..7bdaa35b 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2400,9 +2400,9 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
{
char const* sourceCode = R"(
contract ClientReceipt {
- event Deposit(address indexed _from, bytes32 indexed _id, uint _value) anonymous;
+ event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
function deposit(bytes32 _id, bool _manually) {
- Deposit(msg.sender, _id, msg.value);
+ Deposit(msg.sender, _id, msg.value, 2, "abc");
}
}
)";
@@ -2412,10 +2412,12 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
callContractFunctionWithValue("deposit(bytes32,bool)", value, id);
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(), 2);
+ BOOST_CHECK(m_logs[0].data == encodeArgs("abc"));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 4);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(m_sender));
BOOST_CHECK_EQUAL(m_logs[0].topics[1], h256(id));
+ BOOST_CHECK_EQUAL(m_logs[0].topics[2], h256(value));
+ BOOST_CHECK_EQUAL(m_logs[0].topics[3], h256(2));
}
BOOST_AUTO_TEST_CASE(event_lots_of_data)
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index b4f16913..33e76ec9 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1107,6 +1107,24 @@ BOOST_AUTO_TEST_CASE(event_too_many_indexed)
SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
}
+BOOST_AUTO_TEST_CASE(anonymous_event_four_indexed)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d) anonymous;
+ })";
+ ETH_TEST_CHECK_NO_THROW(parseAndAnalyse(text), "Parsing and Name Resolving Failed");
+}
+
+BOOST_AUTO_TEST_CASE(anonymous_event_too_many_indexed)
+{
+ char const* text = R"(
+ contract c {
+ event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous;
+ })";
+ SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError);
+}
+
BOOST_AUTO_TEST_CASE(event_call)
{
char const* text = R"(