diff options
author | chriseth <chris@ethereum.org> | 2018-10-01 19:20:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 19:20:06 +0800 |
commit | e9f72212ee72312d264311bae37e44cd965798ab (patch) | |
tree | 42cde4865a75eddfe6eea77f8b55f5d2a73164f0 /test | |
parent | 658bef5a3845b78e1f9bc8965bbebbd567adbc1e (diff) | |
parent | 24563dd3ceed506ac404418224c3cf984251caae (diff) | |
download | dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.tar dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.tar.gz dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.tar.bz2 dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.tar.lz dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.tar.xz dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.tar.zst dexon-solidity-e9f72212ee72312d264311bae37e44cd965798ab.zip |
Merge pull request #5104 from ethereum/fuzzer
Do not use compileJSON wrapper in the fuzzer
Diffstat (limited to 'test')
-rw-r--r-- | test/tools/fuzzer.cpp | 71 |
1 files changed, 26 insertions, 45 deletions
diff --git a/test/tools/fuzzer.cpp b/test/tools/fuzzer.cpp index a5a63854..ce4b721f 100644 --- a/test/tools/fuzzer.cpp +++ b/test/tools/fuzzer.cpp @@ -84,12 +84,8 @@ void testConstantOptimizer() } } -void testStandardCompiler() +void runCompiler(string input) { - if (!quiet) - cout << "Testing compiler via JSON interface." << endl; - string input = readStandardInput(); - string outputString(compileStandard(input.c_str(), NULL)); Json::Value output; if (!jsonParseStrict(outputString, output)) @@ -112,52 +108,37 @@ void testStandardCompiler() } } +void testStandardCompiler() +{ + if (!quiet) + cout << "Testing compiler via JSON interface." << endl; + string input = readStandardInput(); + + runCompiler(input); +} + void testCompiler(bool optimize) { if (!quiet) cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl; string input = readStandardInput(); - string outputString(compileJSON(input.c_str(), optimize)); - Json::Value outputJson; - if (!jsonParseStrict(outputString, outputJson)) - { - cout << "Compiler produced invalid JSON output." << endl; - abort(); - } - if (outputJson.isMember("errors")) - { - if (!outputJson["errors"].isArray()) - { - cout << "Output JSON has \"errors\" but it is not an array." << endl; - abort(); - } - for (Json::Value const& error: outputJson["errors"]) - { - string invalid = contains(error.asString(), vector<string>{ - // StandardJSON error types - "Exception", - "InternalCompilerError", - // Old-school error messages - "Internal compiler error", - "Exception during compilation", - "Unknown exception during compilation", - "Unknown exception while generating contract data output", - "Unknown exception while generating source name output", - "Unknown error while generating JSON" - }); - if (!invalid.empty()) - { - cout << "Invalid error: \"" << error.asString() << "\"" << endl; - abort(); - } - } - } - else if (!outputJson.isMember("contracts")) - { - cout << "Output JSON has neither \"errors\" nor \"contracts\"." << endl; - abort(); - } + Json::Value config = Json::objectValue; + config["language"] = "Solidity"; + config["sources"] = Json::objectValue; + config["sources"][""] = Json::objectValue; + config["sources"][""]["content"] = input; + config["settings"] = Json::objectValue; + config["settings"]["optimizer"] = Json::objectValue; + config["settings"]["optimizer"]["enabled"] = optimize; + config["settings"]["optimizer"]["runs"] = 200; + + // Enable all SourceUnit-level outputs. + config["settings"]["outputSelection"]["*"][""][0] = "*"; + // Enable all Contract-level outputs. + config["settings"]["outputSelection"]["*"]["*"][0] = "*"; + + runCompiler(jsonCompactPrint(config)); } } |