mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5104 from ethereum/fuzzer
Do not use compileJSON wrapper in the fuzzer
This commit is contained in:
commit
e9f72212ee
@ -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));
|
string outputString(compileStandard(input.c_str(), NULL));
|
||||||
Json::Value output;
|
Json::Value output;
|
||||||
if (!jsonParseStrict(outputString, 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)
|
void testCompiler(bool optimize)
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl;
|
cout << "Testing compiler " << (optimize ? "with" : "without") << " optimizer." << endl;
|
||||||
string input = readStandardInput();
|
string input = readStandardInput();
|
||||||
|
|
||||||
string outputString(compileJSON(input.c_str(), optimize));
|
Json::Value config = Json::objectValue;
|
||||||
Json::Value outputJson;
|
config["language"] = "Solidity";
|
||||||
if (!jsonParseStrict(outputString, outputJson))
|
config["sources"] = Json::objectValue;
|
||||||
{
|
config["sources"][""] = Json::objectValue;
|
||||||
cout << "Compiler produced invalid JSON output." << endl;
|
config["sources"][""]["content"] = input;
|
||||||
abort();
|
config["settings"] = Json::objectValue;
|
||||||
}
|
config["settings"]["optimizer"] = Json::objectValue;
|
||||||
if (outputJson.isMember("errors"))
|
config["settings"]["optimizer"]["enabled"] = optimize;
|
||||||
{
|
config["settings"]["optimizer"]["runs"] = 200;
|
||||||
if (!outputJson["errors"].isArray())
|
|
||||||
{
|
// Enable all SourceUnit-level outputs.
|
||||||
cout << "Output JSON has \"errors\" but it is not an array." << endl;
|
config["settings"]["outputSelection"]["*"][""][0] = "*";
|
||||||
abort();
|
// Enable all Contract-level outputs.
|
||||||
}
|
config["settings"]["outputSelection"]["*"]["*"][0] = "*";
|
||||||
for (Json::Value const& error: outputJson["errors"])
|
|
||||||
{
|
runCompiler(jsonCompactPrint(config));
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user