[isoltest] Fixes hex (plus alignment) formatting.

This commit is contained in:
Erik Kundt 2019-08-07 12:15:10 +02:00
parent 42290f912b
commit e206ad6c24
3 changed files with 6 additions and 9 deletions

View File

@ -101,7 +101,7 @@ contract C {
// g1() -> FAILURE // g1() -> FAILURE
// h(uint256,uint256): 1, -2 -> 3 // h(uint256,uint256): 1, -2 -> 3
// j(bool): true -> false // j(bool): true -> false
// k(bytes32): 0x10 -> 0x10, 0x10 // k(bytes32): 0x1001 -> 0x1001, 0x1001
// l(): hex"4200efef" -> 8 // l(): hex"4200efef" -> 8
// m(bytes): 32, 32, 0x20 -> 32, 32, 0x20 // m(bytes): 32, 32, 0x20 -> 32, 32, 0x20
// m(bytes): 32, 3, hex"AB33BB" -> 32, 3, left(0xAB33BB) // m(bytes): 32, 3, hex"AB33BB" -> 32, 3, left(0xAB33BB)

View File

@ -21,6 +21,8 @@
#include <liblangutil/Common.h> #include <liblangutil/Common.h>
#include <libdevcore/StringUtils.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <fstream> #include <fstream>
@ -159,13 +161,8 @@ string BytesUtils::formatBoolean(bytes const& _bytes)
string BytesUtils::formatHex(bytes const& _bytes) string BytesUtils::formatHex(bytes const& _bytes)
{ {
stringstream os; u256 value = fromBigEndian<u256>(_bytes);
return toCompactHexWithPrefix(value);
string hex{toHex(_bytes, HexPrefix::Add)};
boost::algorithm::replace_all(hex, "00", "");
os << hex;
return os.str();
} }
string BytesUtils::formatHexString(bytes const& _bytes) string BytesUtils::formatHexString(bytes const& _bytes)

View File

@ -193,7 +193,7 @@ string TestFunctionCall::formatBytesParameters(
fill_n( fill_n(
back_inserter(defaultParameters), back_inserter(defaultParameters),
ceil(_bytes.size() / 32), ceil(_bytes.size() / 32),
Parameter{bytes(), "", ABIType{ABIType::UnsignedDec}, FormatInfo{}} Parameter{bytes(), "", ABIType{ABIType::Hex}, FormatInfo{}}
); );
ContractABIUtils::overwriteParameters(_errorReporter, defaultParameters, _parameters); ContractABIUtils::overwriteParameters(_errorReporter, defaultParameters, _parameters);
os << BytesUtils::formatBytesRange(_bytes, defaultParameters, _highlight); os << BytesUtils::formatBytesRange(_bytes, defaultParameters, _highlight);