| 127 | } |
| 128 | |
| 129 | void FuzzerUtil::runCompiler(std::string const& _input, bool _quiet) |
| 130 | { |
| 131 | if (!_quiet) |
| 132 | std::cout << "Input JSON: " << _input << std::endl; |
| 133 | std::string outputString(solidity_compile(_input.c_str(), nullptr, nullptr)); |
| 134 | if (!_quiet) |
| 135 | std::cout << "Output JSON: " << outputString << std::endl; |
| 136 | |
| 137 | // This should be safe given the above copies the output. |
| 138 | solidity_reset(); |
| 139 | |
| 140 | Json output; |
| 141 | if (!jsonParseStrict(outputString, output)) |
| 142 | { |
| 143 | std::string msg{"Compiler produced invalid JSON output."}; |
| 144 | std::cout << msg << std::endl; |
| 145 | BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg))); |
| 146 | } |
| 147 | if (output.contains("errors")) |
| 148 | for (auto const& error: output["errors"]) |
| 149 | { |
| 150 | std::string invalid = findAnyOf(error["type"].get<std::string>(), std::vector<std::string>{ |
| 151 | "Exception", |
| 152 | "InternalCompilerError" |
| 153 | }); |
| 154 | if (!invalid.empty()) |
| 155 | { |
| 156 | std::string msg = "Invalid error: \"" + error["type"].get<std::string>() + "\""; |
| 157 | std::cout << msg << std::endl; |
| 158 | BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg))); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | void FuzzerUtil::testConstantOptimizer(std::string const& _input, bool _quiet) |
| 164 | { |
nothing calls this directly
no test coverage detected