aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorMathias Baumann <marenz@supradigital.org>2018-12-11 23:42:09 +0800
committerchriseth <chris@ethereum.org>2018-12-18 04:24:37 +0800
commit1b8570f829ead5859c60e92e51e814e3baa50dc9 (patch)
tree149a2918ff1ad9b2ca08056ae034d8dc9657bb9a /test/libsolidity
parent7d3727bbf7e4dedd94b084e9d0549fb4e6960039 (diff)
downloaddexon-solidity-1b8570f829ead5859c60e92e51e814e3baa50dc9.tar.gz
dexon-solidity-1b8570f829ead5859c60e92e51e814e3baa50dc9.tar.zst
dexon-solidity-1b8570f829ead5859c60e92e51e814e3baa50dc9.zip
Only generate sort/search code when interface functions exist
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/Assembly.cpp10
-rw-r--r--test/libsolidity/GasCosts.cpp43
2 files changed, 48 insertions, 5 deletions
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp
index aa10147c..5d8c89a4 100644
--- a/test/libsolidity/Assembly.cpp
+++ b/test/libsolidity/Assembly.cpp
@@ -165,14 +165,14 @@ BOOST_AUTO_TEST_CASE(location_test)
auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--");
vector<SourceLocation> locations =
- vector<SourceLocation>(hasShifts ? 21 : 22, SourceLocation(2, 82, sourceCode)) +
- vector<SourceLocation>(2, SourceLocation(20, 79, sourceCode)) +
- vector<SourceLocation>(1, SourceLocation(8, 17, codegenCharStream)) +
- vector<SourceLocation>(3, SourceLocation(5, 7, codegenCharStream)) +
+ vector<SourceLocation>(4, SourceLocation(2, 82, sourceCode)) +
+ vector<SourceLocation>(1, SourceLocation(8, 17, codegenCharStream)) +
+ vector<SourceLocation>(3, SourceLocation(5, 7, codegenCharStream)) +
vector<SourceLocation>(1, SourceLocation(30, 31, codegenCharStream)) +
vector<SourceLocation>(1, SourceLocation(27, 28, codegenCharStream)) +
vector<SourceLocation>(1, SourceLocation(20, 32, codegenCharStream)) +
- vector<SourceLocation>(1, SourceLocation(5, 7, codegenCharStream)) +
+ vector<SourceLocation>(1, SourceLocation(5, 7, codegenCharStream)) +
+ vector<SourceLocation>(hasShifts ? 19 : 20, SourceLocation(2, 82, sourceCode)) +
vector<SourceLocation>(24, SourceLocation(20, 79, sourceCode)) +
vector<SourceLocation>(1, SourceLocation(49, 58, sourceCode)) +
vector<SourceLocation>(1, SourceLocation(72, 74, sourceCode)) +
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()
}