aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-09-16 18:56:43 +0800
committerchriseth <c@ethdev.com>2016-09-17 17:29:54 +0800
commitdd2f878e594807cb86bdb49bc979c63e2b8d7e81 (patch)
tree5379c5e9b46908bdc779c5b8136a7f320d36e789 /test/libsolidity
parent0bc8476aeaac94f44d85d72865c142ac4151967f (diff)
downloaddexon-solidity-dd2f878e594807cb86bdb49bc979c63e2b8d7e81.tar.gz
dexon-solidity-dd2f878e594807cb86bdb49bc979c63e2b8d7e81.tar.zst
dexon-solidity-dd2f878e594807cb86bdb49bc979c63e2b8d7e81.zip
Test case.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7ee5700c..c8bc7ff9 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7186,6 +7186,33 @@ BOOST_AUTO_TEST_CASE(no_nonpayable_circumvention_by_modifier)
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 0);
}
+BOOST_AUTO_TEST_CASE(mem_resize_is_not_paid_at_call)
+{
+ // This tests that memory resize for return values is not paid during the call, which would
+ // make the gas calculation overly complex. We access the end of the output area before
+ // the call is made.
+ // Tests that this also survivecs the optimizer.
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (uint[200]) {}
+ }
+ contract D {
+ function f(C c) returns (uint) { c.f(); return 7; }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ u160 cAddr = m_contractAddress;
+ compileAndRun(sourceCode, 0, "D");
+ BOOST_CHECK(callContractFunction("f(address)", cAddr) == encodeArgs(u256(7)));
+
+ m_optimize = true;
+
+ compileAndRun(sourceCode, 0, "C");
+ u160 cAddrOpt = m_contractAddress;
+ compileAndRun(sourceCode, 0, "D");
+ BOOST_CHECK(callContractFunction("f(address)", cAddrOpt) == encodeArgs(u256(7)));
+}
BOOST_AUTO_TEST_SUITE_END()