mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixes missing alignment output in isoltest.
This commit is contained in:
parent
9d9a7ebe25
commit
ae67cbde7d
@ -158,12 +158,15 @@ string BytesUtils::formatBoolean(bytes const& _bytes)
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
string BytesUtils::formatHex(bytes const& _bytes)
|
string BytesUtils::formatHex(bytes const& _bytes, bool _shorten)
|
||||||
{
|
{
|
||||||
soltestAssert(!_bytes.empty() && _bytes.size() <= 32, "");
|
soltestAssert(!_bytes.empty() && _bytes.size() <= 32, "");
|
||||||
u256 value = fromBigEndian<u256>(_bytes);
|
u256 value = fromBigEndian<u256>(_bytes);
|
||||||
|
string output = toCompactHexWithPrefix(value);
|
||||||
|
|
||||||
return toCompactHexWithPrefix(value);
|
if (_shorten)
|
||||||
|
return output.substr(0, output.size() - countRightPaddedZeros(_bytes) * 2);
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
string BytesUtils::formatHexString(bytes const& _bytes)
|
string BytesUtils::formatHexString(bytes const& _bytes)
|
||||||
@ -258,7 +261,7 @@ string BytesUtils::formatBytes(
|
|||||||
os << formatBoolean(_bytes);
|
os << formatBoolean(_bytes);
|
||||||
break;
|
break;
|
||||||
case ABIType::Hex:
|
case ABIType::Hex:
|
||||||
os << formatHex(_bytes);
|
os << formatHex(_bytes, _abiType.alignDeclared);
|
||||||
break;
|
break;
|
||||||
case ABIType::HexString:
|
case ABIType::HexString:
|
||||||
os << formatHexString(_bytes);
|
os << formatHexString(_bytes);
|
||||||
@ -271,6 +274,9 @@ string BytesUtils::formatBytes(
|
|||||||
case ABIType::None:
|
case ABIType::None:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_abiType.alignDeclared)
|
||||||
|
return (_abiType.align == ABIType::AlignLeft ? "left(" : "right(") + os.str() + ")";
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ public:
|
|||||||
/// Converts \param _bytes to a soltest-compliant and human-readable
|
/// Converts \param _bytes to a soltest-compliant and human-readable
|
||||||
/// string representation of a byte array which is assumed to hold
|
/// string representation of a byte array which is assumed to hold
|
||||||
/// a hex value.
|
/// a hex value.
|
||||||
static std::string formatHex(bytes const& _bytes);
|
/// The _shorten flag is used to trim leading and trailing zeros.
|
||||||
|
static std::string formatHex(bytes const& _bytes, bool _shorten = false);
|
||||||
|
|
||||||
/// Converts \param _bytes to a soltest-compliant and human-readable
|
/// Converts \param _bytes to a soltest-compliant and human-readable
|
||||||
/// string representation of a byte array which is assumed to hold
|
/// string representation of a byte array which is assumed to hold
|
||||||
|
Loading…
Reference in New Issue
Block a user