aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubtly <subtly@users.noreply.github.com>2015-04-23 18:47:58 +0800
committersubtly <subtly@users.noreply.github.com>2015-04-23 18:47:58 +0800
commit9cf0e47f5e8203556cb9f9f0f6847cc7c62e37b4 (patch)
treef940893c65b4f1beadc39e983b060b64f186b4ba
parentce6db27a5189b8178564c06a4abec92a7b73a732 (diff)
parentfcb772293bcc07f1723c39fa24da14cb5280e78e (diff)
downloaddexon-solidity-9cf0e47f5e8203556cb9f9f0f6847cc7c62e37b4.tar.gz
dexon-solidity-9cf0e47f5e8203556cb9f9f0f6847cc7c62e37b4.tar.zst
dexon-solidity-9cf0e47f5e8203556cb9f9f0f6847cc7c62e37b4.zip
Merge branch 'develop' into discovery
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index 8b926d6c..596f710b 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -2340,6 +2340,49 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(address,bytes32,uint256,bool)")));
}
+BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
+{
+ char const* sourceCode = R"(
+ contract ClientReceipt {
+ event Deposit(uint fixeda, bytes dynx, uint fixedb);
+ function deposit() {
+ Deposit(10, msg.data, 15);
+ }
+ }
+ )";
+ 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 == encodeArgs(10, 4, 15) + FixedHash<4>(dev::sha3("deposit()")).asBytes());
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(uint256,bytes,uint256)")));
+}
+
+BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
+{
+ char const* sourceCode = R"(
+ contract ClientReceipt {
+ bytes x;
+ event Deposit(uint fixeda, bytes dynx, uint fixedb);
+ function deposit() {
+ x.length = 3;
+ x[0] = "A";
+ x[1] = "B";
+ x[2] = "C";
+ Deposit(10, x, 15);
+ }
+ }
+ )";
+ 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 == encodeArgs(10, 3, 15) + asBytes("ABC"));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::sha3(string("Deposit(uint256,bytes,uint256)")));
+}
+
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
{
char const* sourceCode = R"(
@@ -2428,6 +2471,24 @@ BOOST_AUTO_TEST_CASE(sha3_multiple_arguments_with_string_literals)
bytes{0x66, 0x6f, 0x6f})));
}
+BOOST_AUTO_TEST_CASE(sha3_with_bytes)
+{
+ char const* sourceCode = R"(
+ contract c {
+ bytes data;
+ function foo() returns (bool)
+ {
+ data.length = 3;
+ data[0] = "f";
+ data[1] = "o";
+ data[2] = "o";
+ return sha3(data) == sha3("foo");
+ }
+ })";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("foo()") == encodeArgs(true));
+}
+
BOOST_AUTO_TEST_CASE(generic_call)
{
char const* sourceCode = R"**(