diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-09-27 08:53:34 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-11-13 21:54:01 +0800 |
commit | b6c32577523914332ce780928941e197e68eaa00 (patch) | |
tree | 6855cacc063f32235717d8435c31e9b22477cf4f /test | |
parent | c237013911aa5bb6102e1262e6aa62178c0f02e0 (diff) | |
download | dexon-solidity-b6c32577523914332ce780928941e197e68eaa00.tar.gz dexon-solidity-b6c32577523914332ce780928941e197e68eaa00.tar.zst dexon-solidity-b6c32577523914332ce780928941e197e68eaa00.zip |
Remove old libsolc API (compileJSON, compileJSONMulti, compileJSONCallback)
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/LibSolc.cpp | 143 | ||||
-rw-r--r-- | test/tools/fuzzer.cpp | 2 |
2 files changed, 4 insertions, 141 deletions
diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index 94fed7e8..09c08700 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -40,29 +40,9 @@ namespace test namespace { -Json::Value compileSingle(string const& _input) -{ - string output(compileJSON(_input.c_str(), dev::test::Options::get().optimize)); - Json::Value ret; - BOOST_REQUIRE(jsonParseStrict(output, ret)); - return ret; -} - -Json::Value compileMulti(string const& _input, bool _callback) -{ - string output( - _callback ? - compileJSONCallback(_input.c_str(), dev::test::Options::get().optimize, nullptr) : - compileJSONMulti(_input.c_str(), dev::test::Options::get().optimize) - ); - Json::Value ret; - BOOST_REQUIRE(jsonParseStrict(output, ret)); - return ret; -} - Json::Value compile(string const& _input) { - string output(compileStandard(_input.c_str(), nullptr)); + string output(solidity_compile(_input.c_str(), nullptr)); Json::Value ret; BOOST_REQUIRE(jsonParseStrict(output, ret)); return ret; @@ -74,113 +54,16 @@ BOOST_AUTO_TEST_SUITE(LibSolc) BOOST_AUTO_TEST_CASE(read_version) { - string output(version()); + string output(solidity_version()); BOOST_CHECK(output.find(VersionString) == 0); } BOOST_AUTO_TEST_CASE(read_license) { - string output(license()); + string output(solidity_license()); BOOST_CHECK(output.find("GNU GENERAL PUBLIC LICENSE") != string::npos); } -BOOST_AUTO_TEST_CASE(basic_compilation) -{ - char const* input = R"( - { - "sources": { - "fileA": "contract A { }" - } - } - )"; - Json::Value result = compileMulti(input, false); - BOOST_CHECK(result.isObject()); - - // Compare with compileJSONCallback - BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(result), - dev::jsonCompactPrint(compileMulti(input, true)) - ); - - BOOST_CHECK(result["contracts"].isObject()); - BOOST_CHECK(result["contracts"]["fileA:A"].isObject()); - Json::Value contract = result["contracts"]["fileA:A"]; - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["interface"].isString()); - BOOST_CHECK_EQUAL(contract["interface"].asString(), "[]"); - BOOST_CHECK(contract["bytecode"].isString()); - BOOST_CHECK_EQUAL( - dev::test::bytecodeSansMetadata(contract["bytecode"].asString()), - "6080604052348015600f57600080fd5b50603580601d6000396000f3fe6080604052600080fdfe" - ); - BOOST_CHECK(contract["runtimeBytecode"].isString()); - BOOST_CHECK_EQUAL( - dev::test::bytecodeSansMetadata(contract["runtimeBytecode"].asString()), - "6080604052600080fdfe" - ); - BOOST_CHECK(contract["functionHashes"].isObject()); - BOOST_CHECK(contract["gasEstimates"].isObject()); - BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(contract["gasEstimates"]), - "{\"creation\":[66,10600],\"external\":{},\"internal\":{}}" - ); - BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString())); - BOOST_CHECK(result["sources"].isObject()); - BOOST_CHECK(result["sources"]["fileA"].isObject()); - BOOST_CHECK(result["sources"]["fileA"]["AST"].isObject()); - BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(result["sources"]["fileA"]["AST"]), - "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}}," - "\"children\":[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null]," - "\"contractKind\":\"contract\",\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1]," - "\"name\":\"A\",\"nodes\":[null],\"scope\":2},\"id\":1,\"name\":\"ContractDefinition\"," - "\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}" - ); -} - -BOOST_AUTO_TEST_CASE(single_compilation) -{ - Json::Value result = compileSingle("contract A { }"); - BOOST_CHECK(result.isObject()); - - BOOST_CHECK(result["contracts"].isObject()); - BOOST_CHECK(result["contracts"][":A"].isObject()); - Json::Value contract = result["contracts"][":A"]; - BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["interface"].isString()); - BOOST_CHECK_EQUAL(contract["interface"].asString(), "[]"); - BOOST_CHECK(contract["bytecode"].isString()); - BOOST_CHECK_EQUAL( - dev::test::bytecodeSansMetadata(contract["bytecode"].asString()), - "6080604052348015600f57600080fd5b50603580601d6000396000f3fe6080604052600080fdfe" - ); - BOOST_CHECK(contract["runtimeBytecode"].isString()); - BOOST_CHECK_EQUAL( - dev::test::bytecodeSansMetadata(contract["runtimeBytecode"].asString()), - "6080604052600080fdfe" - ); - BOOST_CHECK(contract["functionHashes"].isObject()); - BOOST_CHECK(contract["gasEstimates"].isObject()); - BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(contract["gasEstimates"]), - "{\"creation\":[66,10600],\"external\":{},\"internal\":{}}" - ); - BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString())); - BOOST_CHECK(result["sources"].isObject()); - BOOST_CHECK(result["sources"][""].isObject()); - BOOST_CHECK(result["sources"][""]["AST"].isObject()); - BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(result["sources"][""]["AST"]), - "{\"attributes\":{\"absolutePath\":\"\",\"exportedSymbols\":{\"A\":[1]}}," - "\"children\":[{\"attributes\":{\"baseContracts\":[null],\"contractDependencies\":[null]," - "\"contractKind\":\"contract\",\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1]," - "\"name\":\"A\",\"nodes\":[null],\"scope\":2},\"id\":1,\"name\":\"ContractDefinition\"," - "\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}" - ); -} - BOOST_AUTO_TEST_CASE(standard_compilation) { char const* input = R"( @@ -201,26 +84,6 @@ BOOST_AUTO_TEST_CASE(standard_compilation) BOOST_CHECK(result.isMember("contracts")); } -BOOST_AUTO_TEST_CASE(new_api) -{ - char const* input = R"( - { - "language": "Solidity", - "sources": { - "fileA": { - "content": "contract A { }" - } - } - } - )"; - BOOST_CHECK_EQUAL(string(version()), string(solidity_version())); - BOOST_CHECK_EQUAL(string(license()), string(solidity_license())); - BOOST_CHECK_EQUAL( - string(compileStandard(input, nullptr)), - string(solidity_compile(input, nullptr)) - ); -} - BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/tools/fuzzer.cpp b/test/tools/fuzzer.cpp index bb020f8c..8633454c 100644 --- a/test/tools/fuzzer.cpp +++ b/test/tools/fuzzer.cpp @@ -89,7 +89,7 @@ void testConstantOptimizer(string const& input) void runCompiler(string input) { - string outputString(compileStandard(input.c_str(), nullptr)); + string outputString(solidity_compile(input.c_str(), nullptr)); Json::Value output; if (!jsonParseStrict(outputString, output)) { |