From 3c408a32c42635e3add622b8300f5d2cae37fe43 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 6 Aug 2018 13:30:38 +0100 Subject: Be explicit about which contract to test for in ABIJSON tests --- test/libsolidity/SolidityABIJSON.cpp | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 0b2e23e6..fdb11504 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -40,7 +40,7 @@ class JSONInterfaceChecker public: 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.addSource("", "pragma solidity >=0.0;\n" + _code); @@ -48,7 +48,7 @@ public: m_compilerStack.setOptimiserSettings(dev::test::Options::get().optimize); 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; BOOST_REQUIRE(jsonParseStrict(_expectedInterfaceString, expectedInterface)); 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) @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(empty_contract) )"; char const* interface = "[]"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(multiple_params) } ])"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(view_function) } ])"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -436,7 +436,7 @@ BOOST_AUTO_TEST_CASE(events) ])"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -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) { @@ -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) @@ -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) @@ -641,7 +641,7 @@ BOOST_AUTO_TEST_CASE(constructor_abi) "type": "constructor" } ])"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } BOOST_AUTO_TEST_CASE(payable_constructor_abi) @@ -673,7 +673,7 @@ BOOST_AUTO_TEST_CASE(payable_constructor_abi) "type": "constructor" } ])"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -748,7 +748,7 @@ BOOST_AUTO_TEST_CASE(strings_and_arrays) } ] )"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -800,7 +800,7 @@ BOOST_AUTO_TEST_CASE(include_fallback_function) } ] )"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) @@ -854,7 +854,7 @@ BOOST_AUTO_TEST_CASE(payable_fallback_function) } ] )"; - checkInterface(sourceCode, interface); + checkInterface(sourceCode, "test", interface); } 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) { - char const* text = R"( + char const* sourceCode = R"( pragma experimental ABIEncoderV2; contract C { struct S { uint a; T[] sub; } @@ -931,12 +931,12 @@ BOOST_AUTO_TEST_CASE(return_structs) "type" : "function" }] )"; - checkInterface(text, interface); + checkInterface(sourceCode, "C", interface); } BOOST_AUTO_TEST_CASE(return_structs_with_contracts) { - char const* text = R"( + char const* sourceCode = R"( pragma experimental ABIEncoderV2; contract C { struct S { C[] x; C y; } @@ -974,12 +974,12 @@ BOOST_AUTO_TEST_CASE(return_structs_with_contracts) "type": "function" }] )"; - checkInterface(text, interface); + checkInterface(sourceCode, "C", interface); } BOOST_AUTO_TEST_CASE(event_structs) { - char const* text = R"( + char const* sourceCode = R"( pragma experimental ABIEncoderV2; contract C { struct S { uint a; T[] sub; bytes b; } @@ -1032,12 +1032,12 @@ BOOST_AUTO_TEST_CASE(event_structs) "type": "event" }] )"; - checkInterface(text, interface); + checkInterface(sourceCode, "C", interface); } BOOST_AUTO_TEST_CASE(structs_in_libraries) { - char const* text = R"( + char const* sourceCode = R"( pragma experimental ABIEncoderV2; library L { struct S { uint a; T[] sub; bytes b; } @@ -1096,7 +1096,7 @@ BOOST_AUTO_TEST_CASE(structs_in_libraries) "type": "function" }] )"; - checkInterface(text, interface); + checkInterface(sourceCode, "L", interface); } BOOST_AUTO_TEST_SUITE_END() -- cgit