mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7554 from ethereum/develop
Merge develop into develop_060
This commit is contained in:
@@ -617,6 +617,25 @@ BOOST_AUTO_TEST_CASE(gas_left)
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(selfbalance)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
function f() returns (uint) {
|
||||
return address(this).balance;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
bytes code = compileFirstExpression(sourceCode, {}, {});
|
||||
|
||||
if (dev::test::Options::get().evmVersion() == EVMVersion::istanbul())
|
||||
{
|
||||
bytes expectation({uint8_t(Instruction::SELFBALANCE)});
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ string BytesUtils::formatBytes(
|
||||
os << formatHexString(_bytes);
|
||||
break;
|
||||
case ABIType::String:
|
||||
os << formatString(_bytes);
|
||||
os << formatString(_bytes, _bytes.size() - countRightPaddedZeros(_bytes));
|
||||
break;
|
||||
case ABIType::Failure:
|
||||
break;
|
||||
@@ -311,3 +311,12 @@ string BytesUtils::formatBytesRange(
|
||||
return os.str();
|
||||
}
|
||||
|
||||
size_t BytesUtils::countRightPaddedZeros(bytes const& _bytes)
|
||||
{
|
||||
return find_if(
|
||||
_bytes.rbegin(),
|
||||
_bytes.rend(),
|
||||
[](uint8_t b) { return b != '\0'; }
|
||||
) - _bytes.rbegin();
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,10 @@ public:
|
||||
ParameterList const& _parameters,
|
||||
bool _highlight
|
||||
);
|
||||
|
||||
/// Count the number of zeros between the last non-zero byte and the end of
|
||||
/// \param _bytes.
|
||||
static size_t countRightPaddedZeros(bytes const& _bytes);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
TestFunctionCall(FunctionCall _call): m_call(std::move(_call)) {}
|
||||
|
||||
/// Formats this function call test and applies the format that was detected during parsing.
|
||||
/// If _renderResult is false, the expected result of the call will is used, if it's false
|
||||
/// If _renderResult is false, the expected result of the call will be used, if it's true
|
||||
/// the actual result is used.
|
||||
/// If _highlight is false, it's formatted without colorized highlighting. If it's true, AnsiColorized is
|
||||
/// used to apply a colorized highlighting.
|
||||
|
||||
Reference in New Issue
Block a user