diff options
author | chriseth <chris@ethereum.org> | 2017-09-21 22:56:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-21 22:56:16 +0800 |
commit | bdeb9e52a2211510644fb53df93fb98258b40a65 (patch) | |
tree | d8fb917e7dc27b937cb4505029bbc3c8c1bc1a67 /test/libsolidity/SolidityABIJSON.cpp | |
parent | d7661dd97460250b4e1127b9e7ea91e116143780 (diff) | |
parent | a14fc5ffa1f03d5aa312396a39633d720b04c90a (diff) | |
download | dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.gz dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.bz2 dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.lz dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.xz dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.zst dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.zip |
Merge pull request #2947 from ethereum/develop
Merge develop into release for 0.4.17.
Diffstat (limited to 'test/libsolidity/SolidityABIJSON.cpp')
-rw-r--r-- | test/libsolidity/SolidityABIJSON.cpp | 233 |
1 files changed, 232 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 0512ba1f..e5d9e99c 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -48,7 +48,7 @@ public: Json::Value generatedInterface = m_compilerStack.contractABI(""); Json::Value expectedInterface; - m_reader.parse(_expectedInterfaceString, expectedInterface); + BOOST_REQUIRE(m_reader.parse(_expectedInterfaceString, expectedInterface)); BOOST_CHECK_MESSAGE( expectedInterface == generatedInterface, "Expected:\n" << expectedInterface.toStyledString() << @@ -423,6 +423,8 @@ BOOST_AUTO_TEST_CASE(events) function f(uint a) returns(uint d) { return a * 7; } event e1(uint b, address indexed c); event e2(); + event e2(uint a); + event e3() anonymous; } )"; char const* interface = R"([ @@ -467,6 +469,24 @@ BOOST_AUTO_TEST_CASE(events) "type": "event", "anonymous": false, "inputs": [] + }, + { + "name": "e2", + "type": "event", + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "a", + "type": "uint256" + } + ] + }, + { + "name": "e3", + "type": "event", + "anonymous": true, + "inputs": [] } ])"; @@ -919,6 +939,217 @@ BOOST_AUTO_TEST_CASE(function_type) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(return_structs) +{ + char const* text = R"( + contract C { + struct S { uint a; T[] sub; } + struct T { uint[2] x; } + function f() returns (uint x, S s) { + } + } + )"; + char const* interface = R"( + [{ + "constant" : false, + "inputs" : [], + "name" : "f", + "outputs" : [ + { + "name" : "x", + "type" : "uint256" + }, + { + "components" : [ + { + "name" : "a", + "type" : "uint256" + }, + { + "components" : [ + { + "name" : "x", + "type" : "uint256[2]" + } + ], + "name" : "sub", + "type" : "tuple[]" + } + ], + "name" : "s", + "type" : "tuple" + } + ], + "payable" : false, + "stateMutability" : "nonpayable", + "type" : "function" + }] + )"; + checkInterface(text, interface); +} + +BOOST_AUTO_TEST_CASE(return_structs_with_contracts) +{ + char const* text = R"( + contract C { + struct S { C[] x; C y; } + function f() returns (S s, C c) { + } + } + )"; + char const* interface = R"( + [{ + "constant": false, + "inputs": [], + "name": "f", + "outputs": [ + { + "components": [ + { + "name": "x", + "type": "address[]" + }, + { + "name": "y", + "type": "address" + } + ], + "name": "s", + "type": "tuple" + }, + { + "name": "c", + "type": "address" + } + ], + "payable": false, + "stateMutability" : "nonpayable", + "type": "function" + }] + )"; + checkInterface(text, interface); +} + +BOOST_AUTO_TEST_CASE(event_structs) +{ + char const* text = R"( + contract C { + struct S { uint a; T[] sub; bytes b; } + struct T { uint[2] x; } + event E(T t, S s); + } + )"; + char const *interface = R"( + [{ + "anonymous": false, + "inputs": [ + { + "components": [ + { + "name": "x", + "type": "uint256[2]" + } + ], + "indexed": false, + "name": "t", + "type": "tuple" + }, + { + "components": [ + { + "name": "a", + "type": "uint256" + }, + { + "components": [ + { + "name": "x", + "type": "uint256[2]" + } + ], + "name": "sub", + "type": "tuple[]" + }, + { + "name": "b", + "type": "bytes" + } + ], + "indexed": false, + "name": "s", + "type": "tuple" + } + ], + "name": "E", + "type": "event" + }] + )"; + checkInterface(text, interface); +} + +BOOST_AUTO_TEST_CASE(structs_in_libraries) +{ + char const* text = R"( + library L { + struct S { uint a; T[] sub; bytes b; } + struct T { uint[2] x; } + function f(L.S storage s) {} + function g(L.S s) {} + } + )"; + char const* interface = R"( + [{ + "constant": false, + "inputs": [ + { + "components": [ + { + "name": "a", + "type": "uint256" + }, + { + "components": [ + { + "name": "x", + "type": "uint256[2]" + } + ], + "name": "sub", + "type": "tuple[]" + }, + { + "name": "b", + "type": "bytes" + } + ], + "name": "s", + "type": "tuple" + } + ], + "name": "g", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "s", + "type": "L.S storage" + } + ], + "name": "f", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }] + )"; + checkInterface(text, interface); +} + BOOST_AUTO_TEST_SUITE_END() } |