From cd2a4bc5101ea28661a3fa3a70b6735b68ae70fc Mon Sep 17 00:00:00 2001 From: rustaceanrob Date: Fri, 12 Jun 2026 16:33:34 +0100 Subject: [PATCH] test: Redeclare variable as signed in `util_tests` Assigning `ToIntegral("-1")` to the `optional` `n` is a silent underflow. `BOOST_CHECK_EQUAL` then promotes `int` to `uint64_t`, which also underflows. The correct check is to do this inline. --- src/test/util_tests.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index e26234f8696..6eddd3627c5 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -883,8 +883,7 @@ BOOST_AUTO_TEST_CASE(test_ToIntegralHex) BOOST_CHECK_EQUAL(*n, 0); n = ToIntegral("FfFfFfFfFfFfFfFf", 16); BOOST_CHECK_EQUAL(*n, 0xFfFfFfFfFfFfFfFfULL); - n = ToIntegral("-1", 16); - BOOST_CHECK_EQUAL(*n, -1); + BOOST_CHECK_EQUAL(*ToIntegral("-1", 16), -1); // Invalid values BOOST_CHECK(!ToIntegral("", 16)); BOOST_CHECK(!ToIntegral("-1", 16));