From 293849a26088a16f6187dfdc36bef1d4d83ebb9d Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Fri, 30 Sep 2022 15:05:35 +0200 Subject: univalue: Remove confusing getBool method Drop UniValue::getBool method because it is easy to confuse with the UniValue::get_bool method, and could potentially cause bugs. Unlike get_bool, getBool doesn't ensure that the value is a boolean and returns false for all integer, string, array, and object values instead of throwing an exceptions. The getBool method is also redundant because it is an alias for isTrue. There were only 5 getBool() calls in the codebase, so this commit replaces them with isTrue() or get_bool() calls as appropriate. These changes were originally made by MarcoFalke in https://github.com/bitcoin/bitcoin/pull/26213 but were dropped to limit the scope of that PR. Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> --- src/test/system_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index d5b65b9c08..472b58b4d5 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(run_command) BOOST_CHECK(result.isObject()); const UniValue& success = find_value(result, "success"); BOOST_CHECK(!success.isNull()); - BOOST_CHECK_EQUAL(success.getBool(), true); + BOOST_CHECK_EQUAL(success.get_bool(), true); } { // An invalid command is handled by Boost @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(run_command) BOOST_CHECK(result.isObject()); const UniValue& success = find_value(result, "success"); BOOST_CHECK(!success.isNull()); - BOOST_CHECK_EQUAL(success.getBool(), true); + BOOST_CHECK_EQUAL(success.get_bool(), true); } #endif } -- cgit v1.2.3