aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-09-17 21:25:54 +0800
committerGitHub <noreply@github.com>2016-09-17 21:25:54 +0800
commitaf6afb0415761b53721f89c7f65064807f41cbd3 (patch)
tree006481ce07f5ed6f1690014921f8c559b71dc5b5 /test/libsolidity/SolidityEndToEndTest.cpp
parent4fc6fc2ca59579fae2472df319c2d8d31fe5bde5 (diff)
parenta78e7794225da95d0f875c908025213d6a47cb59 (diff)
downloaddexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.tar
dexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.tar.gz
dexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.tar.bz2
dexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.tar.lz
dexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.tar.xz
dexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.tar.zst
dexon-solidity-af6afb0415761b53721f89c7f65064807f41cbd3.zip
Merge pull request #1107 from ethereum/develop
Version 0.4.2
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7ee5700c..23bd2abc 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7144,6 +7144,23 @@ BOOST_AUTO_TEST_CASE(payable_function)
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 27 + 27);
}
+BOOST_AUTO_TEST_CASE(payable_function_calls_library)
+{
+ char const* sourceCode = R"(
+ library L {
+ function f() returns (uint) { return 7; }
+ }
+ contract C {
+ function f() payable returns (uint) {
+ return L.f();
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "L");
+ compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
+ BOOST_CHECK(callContractFunctionWithValue("f()", 27) == encodeArgs(u256(7)));
+}
+
BOOST_AUTO_TEST_CASE(non_payable_throw)
{
char const* sourceCode = R"(
@@ -7186,6 +7203,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 survives 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()