Test case.

This commit is contained in:
chriseth 2016-09-16 12:56:43 +02:00
parent 0bc8476aea
commit dd2f878e59

View File

@ -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()