aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/ABIEncoderTests.cpp36
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp44
2 files changed, 36 insertions, 44 deletions
diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp
index 4ddf17ce..05158601 100644
--- a/test/libsolidity/ABIEncoderTests.cpp
+++ b/test/libsolidity/ABIEncoderTests.cpp
@@ -424,7 +424,43 @@ BOOST_AUTO_TEST_CASE(function_name_collision)
)
}
+BOOST_AUTO_TEST_CASE(structs)
+{
+ string sourceCode = R"(
+ contract C {
+ struct S { uint16 a; uint16 b; T[] sub; uint16 c; }
+ struct T { uint64[2] x; }
+ S s;
+ event e(uint16, S);
+ function f() returns (uint, S) {
+ uint16 x = 7;
+ s.a = 8;
+ s.b = 9;
+ s.c = 10;
+ s.sub.length = 3;
+ s.sub[0].x[0] = 11;
+ s.sub[1].x[0] = 12;
+ s.sub[2].x[1] = 13;
+ e(x, s);
+ return (x, s);
+ }
+ }
+ )";
+ NEW_ENCODER(
+ compileAndRun(sourceCode, 0, "C");
+ bytes encoded = encodeArgs(
+ u256(7), 0x40,
+ 8, 9, 0x80, 10,
+ 3,
+ 11, 0,
+ 12, 0,
+ 0, 13
+ );
+ BOOST_CHECK(callContractFunction("f()") == encoded);
+ REQUIRE_LOG_DATA(encoded);
+ )
+}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 2bdcbd48..f885b0d3 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -9682,50 +9682,6 @@ BOOST_AUTO_TEST_CASE(contracts_separated_with_comment)
compileAndRun(sourceCode, 0, "C2");
}
-BOOST_AUTO_TEST_CASE(return_structs)
-{
- char const* sourceCode = R"(
- pragma experimental ABIEncoderV2;
- contract C {
- struct S { uint a; T[] sub; }
- struct T { uint[2] x; }
- function f() returns (uint x, S s) {
- x = 7;
- s.a = 8;
- s.sub = new T[](3);
- s.sub[0].x[0] = 9;
- s.sub[1].x[0] = 10;
- s.sub[2].x[1] = 11;
- }
- }
- )";
- // This will throw "unimplemented" until it is implemented.
- BOOST_CHECK_THROW(
- compileAndRun(sourceCode, 0, "C"),
- Exception);
-
-// Will calculate the exact encoding later.
-// BOOST_CHECK(callContractFunction("f()") == encodeArgs(
-// u256(7), u256(0x40),
-// u256(8), u256(0x40),
-// u256(3),
-// // s.sub[0]
-// u256(9), u256(0xc0),
-// // s.sub[1]
-// u256(10), u256(0xe0),
-// // s.sub[2]
-// u256(11), u256(0x100),
-// // s.sub[0].sub
-// u256(2)
-// // s.sub[0].sub[0].a
-// u256(8),
-// u256()
-// // s.sub[1].sub
-// u256(0)
-// // s.sub[2].sub
-// u256(2)
-// ));
-}
BOOST_AUTO_TEST_CASE(include_creation_bytecode_only_once)
{