aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-09-01 19:37:40 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-09-16 19:31:12 +0800
commitc5063d315583270e88a01a0a82a84a68190f6ba1 (patch)
treeba738fb253932ad7cb81bae6d27352aa06de4c7f /test
parent70d70e78160069d28a6b4931c995d0b24c2b09d5 (diff)
downloaddexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.tar
dexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.tar.gz
dexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.tar.bz2
dexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.tar.lz
dexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.tar.xz
dexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.tar.zst
dexon-solidity-c5063d315583270e88a01a0a82a84a68190f6ba1.zip
Use "tuple" for struct types in ABI JSON.
Only use tuple as a type in the ABI (and remove all "anonymous struct" references too)
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityABIJSON.cpp16
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp31
2 files changed, 36 insertions, 11 deletions
diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp
index e4ab54ec..e5d9e99c 100644
--- a/test/libsolidity/SolidityABIJSON.cpp
+++ b/test/libsolidity/SolidityABIJSON.cpp
@@ -973,11 +973,11 @@ BOOST_AUTO_TEST_CASE(return_structs)
}
],
"name" : "sub",
- "type" : "[]"
+ "type" : "tuple[]"
}
],
"name" : "s",
- "type" : ""
+ "type" : "tuple"
}
],
"payable" : false,
@@ -1015,7 +1015,7 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
}
],
"name": "s",
- "type": ""
+ "type": "tuple"
},
{
"name": "c",
@@ -1052,7 +1052,7 @@ BOOST_AUTO_TEST_CASE(event_structs)
],
"indexed": false,
"name": "t",
- "type": ""
+ "type": "tuple"
},
{
"components": [
@@ -1068,7 +1068,7 @@ BOOST_AUTO_TEST_CASE(event_structs)
}
],
"name": "sub",
- "type": "[]"
+ "type": "tuple[]"
},
{
"name": "b",
@@ -1077,7 +1077,7 @@ BOOST_AUTO_TEST_CASE(event_structs)
],
"indexed": false,
"name": "s",
- "type": ""
+ "type": "tuple"
}
],
"name": "E",
@@ -1115,7 +1115,7 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
}
],
"name": "sub",
- "type": "[]"
+ "type": "tuple[]"
},
{
"name": "b",
@@ -1123,7 +1123,7 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
}
],
"name": "s",
- "type": ""
+ "type": "tuple"
}
],
"name": "g",
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 778c12c5..5ab824d3 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -601,7 +601,6 @@ BOOST_AUTO_TEST_CASE(enum_external_type)
BOOST_AUTO_TEST_CASE(external_structs)
{
- ASTPointer<SourceUnit> sourceUnit;
char const* text = R"(
contract Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
@@ -614,7 +613,7 @@ BOOST_AUTO_TEST_CASE(external_structs)
function i(Nested[]) external {}
}
)";
- ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseAndAnalyse(text), "Parsing and name Resolving failed");
+ SourceUnit const* sourceUnit = parseAndAnalyse(text);
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
@@ -627,7 +626,33 @@ BOOST_AUTO_TEST_CASE(external_structs)
}
}
-// TODO: Add a test that checks the signature of library functions taking structs
+BOOST_AUTO_TEST_CASE(external_structs_in_libraries)
+{
+ char const* text = R"(
+ library Test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ struct Empty {}
+ struct Nested { X[2][] a; mapping(uint => uint) m; uint y; }
+ struct X { bytes32 x; Test t; Empty[] e; }
+ function f(ActionChoices, uint, Empty) external {}
+ function g(Test, Nested) external {}
+ function h(function(Nested) external returns (uint)[]) external {}
+ function i(Nested[]) external {}
+ }
+ )";
+ SourceUnit const* sourceUnit = parseAndAnalyse(text);
+ for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ {
+ auto functions = contract->definedFunctions();
+ BOOST_REQUIRE(!functions.empty());
+ BOOST_CHECK_EQUAL("f(Test.ActionChoices,uint256,Test.Empty)", functions[0]->externalSignature());
+ BOOST_CHECK_EQUAL("g(Test,Test.Nested)", functions[1]->externalSignature());
+ BOOST_CHECK_EQUAL("h(function[])", functions[2]->externalSignature());
+ BOOST_CHECK_EQUAL("i(Test.Nested[])", functions[3]->externalSignature());
+ }
+}
+
BOOST_AUTO_TEST_CASE(function_external_call_allowed_conversion)
{