aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/GasCosts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/GasCosts.cpp')
-rw-r--r--test/libsolidity/GasCosts.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp
index 15658a91..c7da3ca0 100644
--- a/test/libsolidity/GasCosts.cpp
+++ b/test/libsolidity/GasCosts.cpp
@@ -82,6 +82,49 @@ BOOST_AUTO_TEST_CASE(string_storage)
}
}
+BOOST_AUTO_TEST_CASE(single_callvaluecheck)
+{
+ string sourceCode = R"(
+ // All functions nonpayable, we can check callvalue at the beginning
+ contract Nonpayable {
+ address a;
+ function f(address b) public {
+ a = b;
+ }
+ function f1(address b) public pure returns (uint c) {
+ return uint(b) + 2;
+ }
+ function f2(address b) public pure returns (uint) {
+ return uint(b) + 8;
+ }
+ function f3(address, uint c) pure public returns (uint) {
+ return c - 5;
+ }
+ }
+ // At least on payable function, we cannot do the optimization.
+ contract Payable {
+ address a;
+ function f(address b) public {
+ a = b;
+ }
+ function f1(address b) public pure returns (uint c) {
+ return uint(b) + 2;
+ }
+ function f2(address b) public pure returns (uint) {
+ return uint(b) + 8;
+ }
+ function f3(address, uint c) payable public returns (uint) {
+ return c - 5;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ size_t bytecodeSizeNonpayable = m_compiler.object("Nonpayable").bytecode.size();
+ size_t bytecodeSizePayable = m_compiler.object("Payable").bytecode.size();
+
+ BOOST_CHECK_EQUAL(bytecodeSizePayable - bytecodeSizeNonpayable, 26);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}