mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Change random function selection
This commit is contained in:
parent
295aef77a4
commit
e400dff607
@ -106,7 +106,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
||||
if (!compilerOutput.has_value())
|
||||
return 0;
|
||||
|
||||
auto r = evmoneUtil.randomFunction();
|
||||
auto r = evmoneUtil.randomFunction(_size);
|
||||
if (!r.has_value())
|
||||
return 0;
|
||||
|
||||
|
@ -75,7 +75,7 @@ optional<string> SolidityCompilationFramework::noInputFunction()
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Json::Value> SolidityCompilationFramework::randomFunction()
|
||||
optional<Json::Value> SolidityCompilationFramework::randomFunction(size_t _seed)
|
||||
{
|
||||
Json::Value const& contractABI = m_compiler.contractABI(m_compiler.lastContractName());
|
||||
unsigned numFunctions = contractABI.size();
|
||||
@ -84,7 +84,7 @@ optional<Json::Value> SolidityCompilationFramework::randomFunction()
|
||||
else
|
||||
{
|
||||
uniform_int_distribution<unsigned> d(0, contractABI.size() - 1);
|
||||
minstd_rand r(contractABI.size());
|
||||
minstd_rand r(_seed);
|
||||
return contractABI[d(r)];
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
std::optional<std::string> noInputFunction();
|
||||
/// @returns FunctionABI of a randomly chosen external function in
|
||||
/// current contract.
|
||||
std::optional<Json::Value> randomFunction();
|
||||
std::optional<Json::Value> randomFunction(size_t _seed);
|
||||
/// @returns name of the last contract in source unit.
|
||||
std::string lastContractName()
|
||||
{
|
||||
@ -181,9 +181,9 @@ public:
|
||||
{
|
||||
return m_compilationFramework.noInputFunction();
|
||||
}
|
||||
std::optional<Json::Value> randomFunction()
|
||||
std::optional<Json::Value> randomFunction(size_t _seed)
|
||||
{
|
||||
return m_compilationFramework.randomFunction();
|
||||
return m_compilationFramework.randomFunction(_seed);
|
||||
}
|
||||
void optSetting(frontend::OptimiserSettings _opt)
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
||||
if (!compilerOutput.has_value())
|
||||
return 0;
|
||||
|
||||
auto r = evmoneUtil.randomFunction();
|
||||
auto r = evmoneUtil.randomFunction(_size);
|
||||
if (!r.has_value())
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user