diff options
author | chriseth <chris@ethereum.org> | 2017-08-24 21:20:49 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-09-16 19:31:12 +0800 |
commit | 70d70e78160069d28a6b4931c995d0b24c2b09d5 (patch) | |
tree | 010da58b648001b2d16848de6658c7d33e4cef62 /test/libsolidity/ABIEncoderTests.cpp | |
parent | 6385641f6e461a1964da793956fbe0ef8cddadd3 (diff) | |
download | dexon-solidity-70d70e78160069d28a6b4931c995d0b24c2b09d5.tar.gz dexon-solidity-70d70e78160069d28a6b4931c995d0b24c2b09d5.tar.zst dexon-solidity-70d70e78160069d28a6b4931c995d0b24c2b09d5.zip |
Implement struct encoder.
Diffstat (limited to 'test/libsolidity/ABIEncoderTests.cpp')
-rw-r--r-- | test/libsolidity/ABIEncoderTests.cpp | 36 |
1 files changed, 36 insertions, 0 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() |