aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-25 02:50:37 +0800
committerGitHub <noreply@github.com>2017-08-25 02:50:37 +0800
commitd7661dd97460250b4e1127b9e7ea91e116143780 (patch)
tree0d909e7aeec373b0559b9d80f8ae9a9e03bdd92b /test/libsolidity/SolidityEndToEndTest.cpp
parentbbb8e64fbee632d1594f6c132b1174591b961207 (diff)
parentdd67e5966f41be0b2ef52041ea726930af74f7e9 (diff)
downloaddexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar
dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.gz
dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.bz2
dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.lz
dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.xz
dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.zst
dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.zip
Merge pull request #2802 from ethereum/develop
Merge develop into release for 0.4.16
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp115
1 files changed, 113 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index d0c5285c..73dd7d22 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3128,7 +3128,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
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, 0x60, 15, 4) + FixedHash<4>(dev::keccak256("deposit()")).asBytes());
+ BOOST_CHECK_EQUAL(toHex(m_logs[0].data), toHex(encodeArgs(10, 0x60, 15, 4) + FixedHash<4>(dev::keccak256("deposit()")).asBytes()));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
@@ -3152,7 +3152,32 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
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, 0x60, 15, 3, string("ABC")));
+ BOOST_CHECK_EQUAL(toHex(m_logs[0].data), toHex(encodeArgs(10, 0x60, 15, 3, string("ABC"))));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
+}
+
+BOOST_AUTO_TEST_CASE(event_really_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 = 31;
+ x[0] = "A";
+ x[1] = "B";
+ x[2] = "C";
+ x[30] = "Z";
+ 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, 0x60, 15, 31, string("ABC") + string(27, 0) + "Z"));
BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
@@ -4402,6 +4427,92 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_struct)
BOOST_CHECK(storageEmpty(m_contractAddress));
}
+BOOST_AUTO_TEST_CASE(array_copy_storage_abi)
+{
+ // NOTE: This does not really test copying from storage to ABI directly,
+ // because it will always copy to memory first.
+ char const* sourceCode = R"(
+ pragma experimental ABIEncoderV2;
+ contract c {
+ uint8[] x;
+ uint16[] y;
+ uint24[] z;
+ uint24[][] w;
+ function test1() returns (uint8[]) {
+ for (uint i = 0; i < 101; ++i)
+ x.push(uint8(i));
+ return x;
+ }
+ function test2() returns (uint16[]) {
+ for (uint i = 0; i < 101; ++i)
+ y.push(uint16(i));
+ return y;
+ }
+ function test3() returns (uint24[]) {
+ for (uint i = 0; i < 101; ++i)
+ z.push(uint24(i));
+ return z;
+ }
+ function test4() returns (uint24[][]) {
+ w.length = 5;
+ for (uint i = 0; i < 5; ++i)
+ for (uint j = 0; j < 101; ++j)
+ w[i].push(uint24(j));
+ return w;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ bytes valueSequence;
+ for (size_t i = 0; i < 101; ++i)
+ valueSequence += toBigEndian(u256(i));
+ BOOST_CHECK(callContractFunction("test1()") == encodeArgs(0x20, 101) + valueSequence);
+ BOOST_CHECK(callContractFunction("test2()") == encodeArgs(0x20, 101) + valueSequence);
+ BOOST_CHECK(callContractFunction("test3()") == encodeArgs(0x20, 101) + valueSequence);
+ BOOST_CHECK(callContractFunction("test4()") ==
+ encodeArgs(0x20, 5, 0xa0, 0xa0 + 102 * 32 * 1, 0xa0 + 102 * 32 * 2, 0xa0 + 102 * 32 * 3, 0xa0 + 102 * 32 * 4) +
+ encodeArgs(101) + valueSequence +
+ encodeArgs(101) + valueSequence +
+ encodeArgs(101) + valueSequence +
+ encodeArgs(101) + valueSequence +
+ encodeArgs(101) + valueSequence
+ );
+}
+
+BOOST_AUTO_TEST_CASE(array_copy_storage_abi_signed)
+{
+ // NOTE: This does not really test copying from storage to ABI directly,
+ // because it will always copy to memory first.
+ char const* sourceCode = R"(
+ contract c {
+ int16[] x;
+ function test() returns (int16[]) {
+ x.push(int16(-1));
+ x.push(int16(-1));
+ x.push(int16(8));
+ x.push(int16(-16));
+ x.push(int16(-2));
+ x.push(int16(6));
+ x.push(int16(8));
+ x.push(int16(-1));
+ return x;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ bytes valueSequence;
+ BOOST_CHECK(callContractFunction("test()") == encodeArgs(0x20, 8,
+ u256(-1),
+ u256(-1),
+ u256(8),
+ u256(-16),
+ u256(-2),
+ u256(6),
+ u256(8),
+ u256(-1)
+ ));
+}
+
BOOST_AUTO_TEST_CASE(array_push)
{
char const* sourceCode = R"(