diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2014-12-19 17:48:59 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2014-12-19 17:48:59 +0800 |
commit | d7d40a13c263d69da0769bece3558496bbcc3bc8 (patch) | |
tree | c826387b4015b617efecca00e1b69e88e45a903c | |
parent | 7795b2a89215686eddf9bdf3e2057295d9ba67af (diff) | |
download | dexon-solidity-d7d40a13c263d69da0769bece3558496bbcc3bc8.tar.gz dexon-solidity-d7d40a13c263d69da0769bece3558496bbcc3bc8.tar.zst dexon-solidity-d7d40a13c263d69da0769bece3558496bbcc3bc8.zip |
Adding const attribute to ABI output
-rw-r--r-- | SolidityABIJSON.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/SolidityABIJSON.cpp b/SolidityABIJSON.cpp index c734009c..62ab0458 100644 --- a/SolidityABIJSON.cpp +++ b/SolidityABIJSON.cpp @@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE(basic_test) char const* interface = R"([ { "name": "f", + "const": false, "inputs": [ { "name": "a", @@ -114,6 +115,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods) char const* interface = R"([ { "name": "f", + "const": false, "inputs": [ { "name": "a", @@ -129,6 +131,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods) }, { "name": "g", + "const": false, "inputs": [ { "name": "b", @@ -156,6 +159,7 @@ BOOST_AUTO_TEST_CASE(multiple_params) char const* interface = R"([ { "name": "f", + "const": false, "inputs": [ { "name": "a", @@ -189,6 +193,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order) char const* interface = R"([ { "name": "c", + "const": false, "inputs": [ { "name": "b", @@ -204,6 +209,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order) }, { "name": "f", + "const": false, "inputs": [ { "name": "a", @@ -222,6 +228,53 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order) checkInterface(sourceCode, interface); } +BOOST_AUTO_TEST_CASE(const_function) +{ + char const* sourceCode = "contract test {\n" + " function foo(uint a, uint b) returns(uint d) { return a + b; }\n" + " function boo(uint32 a) const returns(uint b) { return a * 4; }\n" + "}\n"; + + char const* interface = R"([ + { + "name": "boo", + "const": true, + "inputs": [{ + "name": "a", + "type": "uint32" + }], + "outputs": [ + { + "name": "b", + "type": "uint256" + } + ] + }, + { + "name": "foo", + "const": false, + "inputs": [ + { + "name": "a", + "type": "uint256" + }, + { + "name": "b", + "type": "uint256" + } + ], + "outputs": [ + { + "name": "d", + "type": "uint256" + } + ] + } + ])"; + + checkInterface(sourceCode, interface); +} + BOOST_AUTO_TEST_SUITE_END() } |