aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-07 18:52:40 +0800
committerchriseth <chris@ethereum.org>2017-08-10 21:49:02 +0800
commit95acbc7a9f03eecf837d87eb72f115c1b1650487 (patch)
treee50b229fd7c182343b51a4f62700ed024ba4a209 /test/libsolidity/SolidityEndToEndTest.cpp
parent279e64ae75c5615ca3fc7570a3d533270e43caac (diff)
downloaddexon-solidity-95acbc7a9f03eecf837d87eb72f115c1b1650487.tar.gz
dexon-solidity-95acbc7a9f03eecf837d87eb72f115c1b1650487.tar.zst
dexon-solidity-95acbc7a9f03eecf837d87eb72f115c1b1650487.zip
Some more ABI tests.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index d0c5285c..166c4660 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3157,6 +3157,31 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
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)")));
+}
+
BOOST_AUTO_TEST_CASE(event_indexed_string)
{
char const* sourceCode = R"(
@@ -4402,6 +4427,75 @@ 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"(
+ contract c {
+ uint8[] x;
+ uint16[] y;
+ uint24[] z;
+ 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;
+ }
+ }
+ )";
+ 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_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"(