Skip to content

Commit c6c994c

Browse files
committed
test: remove test-only uint160S
uint160S is a test-only function, and testing input that is not allowed in uint160::FromHex() is superfluous. Tests that can't use uint160::FromHex() because they use input with non-hex digit characters are a) modified by dropping the non-hex digit characters if that provides useful test coverage. b) dropped if the test without non-hex digit characters does not provide useful test coverage, e.g. because it is now duplicated.
1 parent 62cc465 commit c6c994c

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

src/test/uint256_tests.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ static std::string ArrayToString(const unsigned char A[], unsigned int width)
6161
return Stream.str();
6262
}
6363

64-
// Takes hex string in reverse byte order.
65-
inline uint160 uint160S(std::string_view str)
66-
{
67-
uint160 rv;
68-
rv.SetHexDeprecated(str);
69-
return rv;
70-
}
71-
7264
BOOST_AUTO_TEST_CASE( basics ) // constructors, equality, inequality
7365
{
7466
// constructor uint256(vector<char>):
@@ -102,17 +94,12 @@ BOOST_AUTO_TEST_CASE( basics ) // constructors, equality, inequality
10294
BOOST_CHECK_EQUAL(uint256(ZeroL), ZeroL);
10395
BOOST_CHECK_EQUAL(uint256(OneL), OneL);
10496

105-
BOOST_CHECK_EQUAL(uint160S("0x"+R1S.ToString()), R1S);
106-
BOOST_CHECK_EQUAL(uint160S("0x"+R2S.ToString()), R2S);
107-
BOOST_CHECK_EQUAL(uint160S("0x"+ZeroS.ToString()), ZeroS);
108-
BOOST_CHECK_EQUAL(uint160S("0x"+OneS.ToString()), OneS);
109-
BOOST_CHECK_EQUAL(uint160S("0x"+MaxS.ToString()), MaxS);
110-
BOOST_CHECK_EQUAL(uint160S(R1S.ToString()), R1S);
111-
BOOST_CHECK_EQUAL(uint160S(" 0x"+R1S.ToString()+" "), R1S);
112-
BOOST_CHECK_EQUAL(uint160S(" 0x"+R1S.ToString()+"-trash;%^& "), R1S);
113-
BOOST_CHECK_EQUAL(uint160S(" \t \n \n \f\n\r\t\v\t 0x"+R1S.ToString()+" \t \n \n \f\n\r\t\v\t"), R1S);
114-
BOOST_CHECK_EQUAL(uint160S(""), ZeroS);
115-
BOOST_CHECK_EQUAL(R1S, uint160S(R1ArrayHex));
97+
BOOST_CHECK_EQUAL(uint160::FromHex(R1S.ToString()).value(), R1S);
98+
BOOST_CHECK_EQUAL(uint160::FromHex(R2S.ToString()).value(), R2S);
99+
BOOST_CHECK_EQUAL(uint160::FromHex(ZeroS.ToString()).value(), ZeroS);
100+
BOOST_CHECK_EQUAL(uint160::FromHex(OneS.ToString()).value(), OneS);
101+
BOOST_CHECK_EQUAL(uint160::FromHex(MaxS.ToString()).value(), MaxS);
102+
BOOST_CHECK_EQUAL(uint160::FromHex(std::string_view{R1ArrayHex + 24, 40}).value(), R1S);
116103

117104
BOOST_CHECK_EQUAL(uint160(R1S), R1S);
118105
BOOST_CHECK_EQUAL(uint160(ZeroS), ZeroS);

0 commit comments

Comments
 (0)