aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index c40a027a..b46b405d 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5383,6 +5383,33 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4), u256(17)));
}
+BOOST_AUTO_TEST_CASE(using_library_structs)
+{
+ char const* sourceCode = R"(
+ library Lib {
+ struct Data { uint a; uint[] b; }
+ function set(Data storage _s)
+ {
+ _s.a = 7;
+ _s.b.length = 20;
+ _s.b[19] = 8;
+ }
+ }
+ contract Test {
+ mapping(string => Lib.Data) data;
+ function f() returns (uint a, uint b)
+ {
+ Lib.set(data["abc"]);
+ a = data["abc"].a;
+ b = data["abc"].b[19];
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Lib");
+ compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(7), u256(8)));
+}
+
BOOST_AUTO_TEST_CASE(short_strings)
{
// This test verifies that the byte array encoding that combines length and data works