aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-04 17:05:57 +0800
committerchriseth <c@ethdev.com>2015-10-06 20:20:06 +0800
commitce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc (patch)
treeea0f50129f8e1837f3fcef38f8101b23e6e703c6 /test
parent421dcf4c1a38a5e691aec5d791155adbcf732c90 (diff)
downloaddexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.tar
dexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.tar.gz
dexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.tar.bz2
dexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.tar.lz
dexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.tar.xz
dexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.tar.zst
dexon-solidity-ce25ddfa6a9b8cfff08b4a05591dcc3b4a8b63cc.zip
Encode storage items correctly for library calls.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index c40a027a..26185b41 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5383,6 +5383,32 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4), u256(17)));
}
+BOOST_AUTO_TEST_CASE(differentiate_storage_and_memory_in_libraries)
+{
+ char const* sourceCode = R"(
+ library Lib {
+ function f(uint[] storage x) returns (uint) { return 1; }
+ function f(uint[] memory x) returns (uint) { return 2; }
+ }
+ contract Test {
+ uint[] data;
+ function f() returns (uint a,)
+ {
+ uint[] memory d = data;
+ Lib.f(d)
+ data["abc"].length = 20;
+ data["abc"][4] = 9;
+ data["abc"][17] = 3;
+ a = Lib.find(data["abc"], 9);
+ b = Lib.find(data["abc"], 3);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Lib");
+ compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4), u256(17)));
+}
+
BOOST_AUTO_TEST_CASE(short_strings)
{
// This test verifies that the byte array encoding that combines length and data works