Minor refactoring

This commit is contained in:
Bhargava Shastry 2021-04-07 10:39:52 +02:00
parent 7b64e660c6
commit 7b1ade9223
2 changed files with 5 additions and 10 deletions

View File

@ -150,14 +150,10 @@ string fixedBytes(
}
}
std::string ValueGenerator::addressLiteral(bool _hexPrefix)
std::string ValueGenerator::addressLiteral()
{
std::uniform_int_distribution<size_t> dist(0, m_addresses.size() - 1);
std::string addressLiteral;
if (_hexPrefix)
addressLiteral = "0x";
addressLiteral += m_addresses[dist(m_rand)].hex();
return addressLiteral;
return "0x" + m_addresses[dist(m_rand)].hex();
}
void ValueGenerator::initialiseType(TypeInfo& _t)
@ -190,8 +186,7 @@ void ValueGenerator::initialiseType(TypeInfo& _t)
_t.value += addressLiteral();
break;
case Type::Function:
_t.value += "0x" +
addressLiteral(false) +
_t.value += addressLiteral() +
":" +
"0x" +
fixedBytes(static_cast<size_t>(FixedBytesWidth::Bytes4), m_rand(), true);

View File

@ -180,10 +180,10 @@ public:
std::vector<ArrayInfo>& _arrayInfo,
TypeInfo& _typeInfo
);
std::string addressLiteral(bool _hexPrefix = true);
std::string addressLiteral();
private:
std::ostringstream m_stream;
std::minstd_rand m_rand;
std::mt19937_64 m_rand;
Json::Value const& m_type;
std::bernoulli_distribution m_bernoulli;
std::vector<solidity::util::h160> m_addresses;