From ac192ff4c14fc383e5428eef46bd719e4a6a80fe Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 4 Dec 2020 18:59:36 +0000 Subject: [PATCH] Drop the util::u160 type --- libsolutil/Common.h | 1 - libsolutil/CommonData.h | 3 +-- test/libsolutil/FixedHash.cpp | 9 --------- test/libsolutil/StringUtils.cpp | 7 ------- 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/libsolutil/Common.h b/libsolutil/Common.h index 1945f2074..75de12747 100644 --- a/libsolutil/Common.h +++ b/libsolutil/Common.h @@ -65,7 +65,6 @@ using bytesConstRef = util::vector_ref; using bigint = boost::multiprecision::number>; using u256 = boost::multiprecision::number>; using s256 = boost::multiprecision::number>; -using u160 = boost::multiprecision::number>; // Map types. using StringMap = std::map; diff --git a/libsolutil/CommonData.h b/libsolutil/CommonData.h index ec858777e..d5572d6f8 100644 --- a/libsolutil/CommonData.h +++ b/libsolutil/CommonData.h @@ -373,7 +373,7 @@ inline void toBigEndian(T _val, Out& o_out) /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. /// @a In will typically be either std::string or bytes. -/// @a T will typically by unsigned, u160, u256 or bigint. +/// @a T will typically by unsigned, u256 or bigint. template inline T fromBigEndian(In const& _bytes) { @@ -383,7 +383,6 @@ inline T fromBigEndian(In const& _bytes) return ret; } inline bytes toBigEndian(u256 _val) { bytes ret(32); toBigEndian(_val, ret); return ret; } -inline bytes toBigEndian(u160 _val) { bytes ret(20); toBigEndian(_val, ret); return ret; } /// Convenience function for toBigEndian. /// @returns a byte array just big enough to represent @a _val. diff --git a/test/libsolutil/FixedHash.cpp b/test/libsolutil/FixedHash.cpp index 4efe0a9e1..67397e9e1 100644 --- a/test/libsolutil/FixedHash.cpp +++ b/test/libsolutil/FixedHash.cpp @@ -173,12 +173,6 @@ BOOST_AUTO_TEST_CASE(converting_constructor) BOOST_AUTO_TEST_CASE(arith_constructor) { - FixedHash<20> a(u160(0x1234)); - BOOST_CHECK_EQUAL( - a.hex(), - "0000000000000000000000000000000000001234" - ); - FixedHash<32> b(u256(0x12340000)); BOOST_CHECK_EQUAL( b.hex(), @@ -190,9 +184,6 @@ BOOST_AUTO_TEST_CASE(arith_constructor) BOOST_AUTO_TEST_CASE(to_arith) { - FixedHash<20> a{}; - BOOST_CHECK_EQUAL(u160(a), 0); - FixedHash<32> b("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); BOOST_CHECK_EQUAL(u256(b), u256("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); } diff --git a/test/libsolutil/StringUtils.cpp b/test/libsolutil/StringUtils.cpp index f678c0da7..0ef61cb0a 100644 --- a/test/libsolutil/StringUtils.cpp +++ b/test/libsolutil/StringUtils.cpp @@ -125,12 +125,6 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable) BOOST_CHECK_EQUAL(formatNumberReadable(u256(0x100000000)), "2**32"); BOOST_CHECK_EQUAL(formatNumberReadable(u256(0xFFFFffff)), "2**32 - 1"); - u160 a = 0; - for (int i = 0; i < 20; i++) - { - a <<= 8; - a |= 0x55; - } u256 b = 0; for (int i = 0; i < 32; i++) { @@ -144,7 +138,6 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable) u256(0xFFFFffffFFFFffff) << 128 | u256(0xFFFFffffFFFFffff) << 64 | u256(0xFFFFffffFFFFffff); - BOOST_CHECK_EQUAL(formatNumberReadable(a, true), "0x5555...{+32 more}...5555"); BOOST_CHECK_EQUAL(formatNumberReadable(b, true), "0x5555...{+56 more}...5555"); BOOST_CHECK_EQUAL(formatNumberReadable(c, true), "0xABCD...{+56 more}...6789"); BOOST_CHECK_EQUAL(formatNumberReadable(d, true), "0xAAAAaaaaAAAAaaab * 2**192 - 1");