Provide access to scoped structs.

This commit is contained in:
chriseth
2015-10-06 14:20:06 +02:00
parent bc609c55c0
commit bf5b387954
8 changed files with 72 additions and 21 deletions
+27
View File
@@ -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