mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4694 from ethereum/test-abijson
Be explicit about which contract to test for in ABIJSON tests
This commit is contained in:
commit
0449b6446e
@ -40,7 +40,7 @@ class JSONInterfaceChecker
|
|||||||
public:
|
public:
|
||||||
JSONInterfaceChecker(): m_compilerStack() {}
|
JSONInterfaceChecker(): m_compilerStack() {}
|
||||||
|
|
||||||
void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString)
|
void checkInterface(std::string const& _code, std::string const& _contractName, std::string const& _expectedInterfaceString)
|
||||||
{
|
{
|
||||||
m_compilerStack.reset(false);
|
m_compilerStack.reset(false);
|
||||||
m_compilerStack.addSource("", "pragma solidity >=0.0;\n" + _code);
|
m_compilerStack.addSource("", "pragma solidity >=0.0;\n" + _code);
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
m_compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
|
m_compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
|
||||||
BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed");
|
BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed");
|
||||||
|
|
||||||
Json::Value generatedInterface = m_compilerStack.contractABI(m_compilerStack.lastContractName());
|
Json::Value generatedInterface = m_compilerStack.contractABI(_contractName);
|
||||||
Json::Value expectedInterface;
|
Json::Value expectedInterface;
|
||||||
BOOST_REQUIRE(jsonParseStrict(_expectedInterfaceString, expectedInterface));
|
BOOST_REQUIRE(jsonParseStrict(_expectedInterfaceString, expectedInterface));
|
||||||
BOOST_CHECK_MESSAGE(
|
BOOST_CHECK_MESSAGE(
|
||||||
@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(empty_contract)
|
BOOST_AUTO_TEST_CASE(empty_contract)
|
||||||
@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(empty_contract)
|
|||||||
)";
|
)";
|
||||||
char const* interface = "[]";
|
char const* interface = "[]";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_methods)
|
BOOST_AUTO_TEST_CASE(multiple_methods)
|
||||||
@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_params)
|
BOOST_AUTO_TEST_CASE(multiple_params)
|
||||||
@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
||||||
@ -248,7 +248,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(view_function)
|
BOOST_AUTO_TEST_CASE(view_function)
|
||||||
@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(view_function)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(pure_function)
|
BOOST_AUTO_TEST_CASE(pure_function)
|
||||||
@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(pure_function)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(events)
|
BOOST_AUTO_TEST_CASE(events)
|
||||||
@ -436,7 +436,7 @@ BOOST_AUTO_TEST_CASE(events)
|
|||||||
|
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(events_anonymous)
|
BOOST_AUTO_TEST_CASE(events_anonymous)
|
||||||
@ -456,7 +456,7 @@ BOOST_AUTO_TEST_CASE(events_anonymous)
|
|||||||
|
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(inherited)
|
BOOST_AUTO_TEST_CASE(inherited)
|
||||||
@ -531,7 +531,7 @@ BOOST_AUTO_TEST_CASE(inherited)
|
|||||||
}])";
|
}])";
|
||||||
|
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "Derived", interface);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
|
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
|
||||||
{
|
{
|
||||||
@ -575,7 +575,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
|
|||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
|
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
|
BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
|
||||||
@ -609,7 +609,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter)
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(constructor_abi)
|
BOOST_AUTO_TEST_CASE(constructor_abi)
|
||||||
@ -641,7 +641,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi)
|
|||||||
"type": "constructor"
|
"type": "constructor"
|
||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(payable_constructor_abi)
|
BOOST_AUTO_TEST_CASE(payable_constructor_abi)
|
||||||
@ -673,7 +673,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi)
|
|||||||
"type": "constructor"
|
"type": "constructor"
|
||||||
}
|
}
|
||||||
])";
|
])";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(return_param_in_abi)
|
BOOST_AUTO_TEST_CASE(return_param_in_abi)
|
||||||
@ -719,7 +719,7 @@ BOOST_AUTO_TEST_CASE(return_param_in_abi)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(strings_and_arrays)
|
BOOST_AUTO_TEST_CASE(strings_and_arrays)
|
||||||
@ -748,7 +748,7 @@ BOOST_AUTO_TEST_CASE(strings_and_arrays)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(library_function)
|
BOOST_AUTO_TEST_CASE(library_function)
|
||||||
@ -780,7 +780,7 @@ BOOST_AUTO_TEST_CASE(library_function)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(include_fallback_function)
|
BOOST_AUTO_TEST_CASE(include_fallback_function)
|
||||||
@ -800,7 +800,7 @@ BOOST_AUTO_TEST_CASE(include_fallback_function)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(payable_function)
|
BOOST_AUTO_TEST_CASE(payable_function)
|
||||||
@ -834,7 +834,7 @@ BOOST_AUTO_TEST_CASE(payable_function)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(payable_fallback_function)
|
BOOST_AUTO_TEST_CASE(payable_fallback_function)
|
||||||
@ -854,7 +854,7 @@ BOOST_AUTO_TEST_CASE(payable_fallback_function)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(function_type)
|
BOOST_AUTO_TEST_CASE(function_type)
|
||||||
@ -881,12 +881,12 @@ BOOST_AUTO_TEST_CASE(function_type)
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
)";
|
)";
|
||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, "test", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(return_structs)
|
BOOST_AUTO_TEST_CASE(return_structs)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* sourceCode = R"(
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
contract C {
|
contract C {
|
||||||
struct S { uint a; T[] sub; }
|
struct S { uint a; T[] sub; }
|
||||||
@ -931,12 +931,12 @@ BOOST_AUTO_TEST_CASE(return_structs)
|
|||||||
"type" : "function"
|
"type" : "function"
|
||||||
}]
|
}]
|
||||||
)";
|
)";
|
||||||
checkInterface(text, interface);
|
checkInterface(sourceCode, "C", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
|
BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* sourceCode = R"(
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
contract C {
|
contract C {
|
||||||
struct S { C[] x; C y; }
|
struct S { C[] x; C y; }
|
||||||
@ -974,12 +974,12 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts)
|
|||||||
"type": "function"
|
"type": "function"
|
||||||
}]
|
}]
|
||||||
)";
|
)";
|
||||||
checkInterface(text, interface);
|
checkInterface(sourceCode, "C", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(event_structs)
|
BOOST_AUTO_TEST_CASE(event_structs)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* sourceCode = R"(
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
contract C {
|
contract C {
|
||||||
struct S { uint a; T[] sub; bytes b; }
|
struct S { uint a; T[] sub; bytes b; }
|
||||||
@ -1032,12 +1032,12 @@ BOOST_AUTO_TEST_CASE(event_structs)
|
|||||||
"type": "event"
|
"type": "event"
|
||||||
}]
|
}]
|
||||||
)";
|
)";
|
||||||
checkInterface(text, interface);
|
checkInterface(sourceCode, "C", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(structs_in_libraries)
|
BOOST_AUTO_TEST_CASE(structs_in_libraries)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* sourceCode = R"(
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
library L {
|
library L {
|
||||||
struct S { uint a; T[] sub; bytes b; }
|
struct S { uint a; T[] sub; bytes b; }
|
||||||
@ -1096,7 +1096,7 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries)
|
|||||||
"type": "function"
|
"type": "function"
|
||||||
}]
|
}]
|
||||||
)";
|
)";
|
||||||
checkInterface(text, interface);
|
checkInterface(sourceCode, "L", interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user