Merge remote-tracking branch 'origin/develop' into develop_060

This commit is contained in:
chriseth
2019-10-28 15:21:49 +01:00
67 changed files with 182 additions and 165 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ private:
bytes const& m_metadata;
};
boost::optional<map<string, string>> parseCBORMetadata(bytes const& _metadata)
std::optional<map<string, string>> parseCBORMetadata(bytes const& _metadata)
{
try
{
+2 -3
View File
@@ -21,9 +21,8 @@
#include <libdevcore/CommonData.h>
#include <boost/optional.hpp>
#include <map>
#include <optional>
#include <string>
namespace dev
@@ -48,7 +47,7 @@ std::string bytecodeSansMetadata(std::string const& _bytecode);
/// - bytes into hex strings
/// - booleans into "true"/"false" strings
/// - everything else is invalid
boost::optional<std::map<std::string, std::string>> parseCBORMetadata(bytes const& _metadata);
std::optional<std::map<std::string, std::string>> parseCBORMetadata(bytes const& _metadata);
/// Expects a serialised metadata JSON and returns true if the
/// content is valid metadata.
+1 -1
View File
@@ -184,7 +184,7 @@ bool EVMVersionRestrictedTestCase::validateSettings(langutil::EVMVersion _evmVer
break;
versionString = versionString.substr(versionBegin);
boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
std::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
if (!version)
throw runtime_error("Invalid EVM version: \"" + versionString + "\"");
+5 -5
View File
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_SUITE(IterateReplacing)
BOOST_AUTO_TEST_CASE(no_replacement)
{
vector<string> v{"abc", "def", "ghi"};
function<boost::optional<vector<string>>(string&)> f = [](string&) -> boost::optional<vector<string>> { return {}; };
function<std::optional<vector<string>>(string&)> f = [](string&) -> std::optional<vector<string>> { return {}; };
iterateReplacing(v, f);
vector<string> expectation{"abc", "def", "ghi"};
BOOST_CHECK(v == expectation);
@@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(no_replacement)
BOOST_AUTO_TEST_CASE(empty_input)
{
vector<string> v;
function<boost::optional<vector<string>>(string&)> f = [](string&) -> boost::optional<vector<string>> { return {}; };
function<std::optional<vector<string>>(string&)> f = [](string&) -> std::optional<vector<string>> { return {}; };
iterateReplacing(v, f);
vector<string> expectation;
BOOST_CHECK(v == expectation);
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(empty_input)
BOOST_AUTO_TEST_CASE(delete_some)
{
vector<string> v{"abc", "def", "ghi"};
function<boost::optional<vector<string>>(string&)> f = [](string& _s) -> boost::optional<vector<string>> {
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
if (_s == "def")
return vector<string>();
else
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(delete_some)
BOOST_AUTO_TEST_CASE(inject_some_start)
{
vector<string> v{"abc", "def", "ghi"};
function<boost::optional<vector<string>>(string&)> f = [](string& _s) -> boost::optional<vector<string>> {
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
if (_s == "abc")
return vector<string>{"x", "y"};
else
@@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(inject_some_start)
BOOST_AUTO_TEST_CASE(inject_some_end)
{
vector<string> v{"abc", "def", "ghi"};
function<boost::optional<vector<string>>(string&)> f = [](string& _s) -> boost::optional<vector<string>> {
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
if (_s == "ghi")
return vector<string>{"x", "y"};
else
+3 -3
View File
@@ -34,11 +34,11 @@
#include <libevmasm/Assembly.h>
#include <boost/optional.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <string>
#include <memory>
#include <optional>
#include <string>
using namespace std;
using namespace langutil;
@@ -54,7 +54,7 @@ namespace test
namespace
{
boost::optional<Error> parseAndReturnFirstError(
std::optional<Error> parseAndReturnFirstError(
string const& _source,
bool _assemble = false,
bool _allowWarnings = true,
+1 -1
View File
@@ -42,7 +42,7 @@ map<string, string> requireParsedCBORMetadata(bytes const& _bytecode)
{
bytes cborMetadata = dev::test::onlyMetadata(_bytecode);
BOOST_REQUIRE(!cborMetadata.empty());
boost::optional<map<string, string>> tmp = dev::test::parseCBORMetadata(cborMetadata);
std::optional<map<string, string>> tmp = dev::test::parseCBORMetadata(cborMetadata);
BOOST_REQUIRE(tmp);
return *tmp;
}
+1 -1
View File
@@ -104,7 +104,7 @@ public:
/// @returns the number of instructions in the given bytecode, not taking the metadata hash
/// into account.
size_t numInstructions(bytes const& _bytecode, boost::optional<Instruction> _which = boost::optional<Instruction>{})
size_t numInstructions(bytes const& _bytecode, std::optional<Instruction> _which = std::optional<Instruction>{})
{
bytes realCode = bytecodeSansMetadata(_bytecode);
BOOST_REQUIRE_MESSAGE(!realCode.empty(), "Invalid or missing metadata in bytecode.");
+5 -5
View File
@@ -141,14 +141,14 @@ string functionSignatureFromABI(Json::Value const& _functionABI)
}
boost::optional<dev::solidity::test::ParameterList> ContractABIUtils::parametersFromJsonOutputs(
std::optional<dev::solidity::test::ParameterList> ContractABIUtils::parametersFromJsonOutputs(
ErrorReporter& _errorReporter,
Json::Value const& _contractABI,
string const& _functionSignature
)
{
if (!_contractABI)
return boost::none;
return std::nullopt;
for (auto const& function: _contractABI)
if (_functionSignature == functionSignatureFromABI(function))
@@ -177,17 +177,17 @@ boost::optional<dev::solidity::test::ParameterList> ContractABIUtils::parameters
"Could not convert \"" + type +
"\" to internal ABI type representation. Falling back to default encoding."
);
return boost::none;
return std::nullopt;
}
finalParams += inplaceTypeParams;
inplaceTypeParams.clear();
}
return boost::optional<ParameterList>(finalParams + dynamicTypeParams);
return std::optional<ParameterList>(finalParams + dynamicTypeParams);
}
return boost::none;
return std::nullopt;
}
bool ContractABIUtils::appendTypesFromName(
+1 -1
View File
@@ -42,7 +42,7 @@ public:
/// a list of internal type representations of isoltest.
/// Creates parameters from Contract ABI and is used to generate values for
/// auto-correction during interactive update routine.
static boost::optional<ParameterList> parametersFromJsonOutputs(
static std::optional<ParameterList> parametersFromJsonOutputs(
ErrorReporter& _errorReporter,
Json::Value const& _contractABI,
std::string const& _functionSignature
+1 -1
View File
@@ -24,11 +24,11 @@
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
#include <fstream>
#include <memory>
#include <optional>
#include <stdexcept>
using namespace dev;
+9 -9
View File
@@ -20,8 +20,8 @@
#include <libdevcore/AnsiColorized.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/optional/optional.hpp>
#include <optional>
#include <stdexcept>
#include <string>
@@ -124,12 +124,12 @@ string TestFunctionCall::format(
if (!matchesExpectation())
{
boost::optional<ParameterList> abiParams;
std::optional<ParameterList> abiParams;
if (isFailure)
{
if (!output.empty())
abiParams = boost::make_optional(ContractABIUtils::failureParameters(output));
abiParams = ContractABIUtils::failureParameters(output);
}
else
abiParams = ContractABIUtils::parametersFromJsonOutputs(
@@ -139,7 +139,7 @@ string TestFunctionCall::format(
);
string bytesOutput = abiParams ?
BytesUtils::formatRawBytes(output, abiParams.get(), _linePrefix) :
BytesUtils::formatRawBytes(output, abiParams.value(), _linePrefix) :
BytesUtils::formatRawBytes(
output,
ContractABIUtils::defaultParameters(ceil(output.size() / 32)),
@@ -208,7 +208,7 @@ string TestFunctionCall::formatBytesParameters(
}
else
{
boost::optional<ParameterList> abiParams = ContractABIUtils::parametersFromJsonOutputs(
std::optional<ParameterList> abiParams = ContractABIUtils::parametersFromJsonOutputs(
_errorReporter,
m_contractABI,
_signature
@@ -216,17 +216,17 @@ string TestFunctionCall::formatBytesParameters(
if (abiParams)
{
boost::optional<ParameterList> preferredParams = ContractABIUtils::preferredParameters(
std::optional<ParameterList> preferredParams = ContractABIUtils::preferredParameters(
_errorReporter,
_parameters,
abiParams.get(),
abiParams.value(),
_bytes
);
if (preferredParams)
{
ContractABIUtils::overwriteParameters(_errorReporter, preferredParams.get(), abiParams.get());
os << BytesUtils::formatBytesRange(_bytes, preferredParams.get(), _highlight);
ContractABIUtils::overwriteParameters(_errorReporter, preferredParams.value(), abiParams.value());
os << BytesUtils::formatBytesRange(_bytes, preferredParams.value(), _highlight);
}
}
else
+3 -3
View File
@@ -27,11 +27,11 @@
#include <libsolidity/interface/OptimiserSettings.h>
#include <boost/optional.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <string>
#include <memory>
#include <optional>
#include <string>
using namespace std;
using namespace langutil;
@@ -63,7 +63,7 @@ std::pair<bool, ErrorList> parse(string const& _source)
return {false, {}};
}
boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
std::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
{
bool success;
ErrorList errors;
+3 -3
View File
@@ -31,11 +31,11 @@
#include <liblangutil/Scanner.h>
#include <liblangutil/ErrorReporter.h>
#include <boost/optional.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <string>
#include <memory>
#include <optional>
#include <string>
using namespace std;
using namespace dev;
@@ -72,7 +72,7 @@ bool parse(string const& _source, Dialect const& _dialect, ErrorReporter& errorR
return false;
}
boost::optional<Error> parseAndReturnFirstError(string const& _source, Dialect const& _dialect, bool _allowWarnings = true)
std::optional<Error> parseAndReturnFirstError(string const& _source, Dialect const& _dialect, bool _allowWarnings = true)
{
ErrorList errors;
ErrorReporter errorReporter(errors);
+2 -2
View File
@@ -350,7 +350,7 @@ void setupTerminal()
#endif
}
boost::optional<TestStats> runTestSuite(
std::optional<TestStats> runTestSuite(
TestCreator _testCaseCreator,
TestOptions const& _options,
fs::path const& _basePath,
@@ -364,7 +364,7 @@ boost::optional<TestStats> runTestSuite(
if (!fs::exists(testPath) || !fs::is_directory(testPath))
{
cerr << _name << " tests not found. Use the --testpath argument." << endl;
return {};
return std::nullopt;
}
TestStats stats = TestTool::processPath(
+12
View File
@@ -31,6 +31,18 @@ void yulFuzzerUtil::interpret(
InterpreterState state;
state.maxTraceSize = _maxTraceSize;
state.maxSteps = _maxSteps;
// Add 64 bytes of pseudo-randomly generated calldata so that
// calldata opcodes perform non trivial work.
state.calldata = {
0xe9, 0x96, 0x40, 0x7d, 0xa5, 0xda, 0xb0, 0x2d,
0x97, 0xf5, 0xc3, 0x44, 0xd7, 0x65, 0x0a, 0xd8,
0x2c, 0x14, 0x3a, 0xf3, 0xe7, 0x40, 0x0f, 0x1e,
0x67, 0xce, 0x90, 0x44, 0x2e, 0x92, 0xdb, 0x88,
0xb8, 0x43, 0x9c, 0x41, 0x42, 0x08, 0xf1, 0xd7,
0x65, 0xe9, 0x7f, 0xeb, 0x7b, 0xb9, 0x56, 0x9f,
0xc7, 0x60, 0x5f, 0x7c, 0xcd, 0xfb, 0x92, 0xcd,
0x8e, 0xf3, 0x9b, 0xe4, 0x4f, 0x6c, 0x14, 0xde
};
Interpreter interpreter(state, _dialect);
interpreter(*_ast);
state.dumpTraceAndState(_os);