Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2024-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.4//6#include <node/warnings.h>7#include <util/translation.h>9#include <test/util/setup_common.h>11#include <boost/test/unit_test.hpp>13BOOST_FIXTURE_TEST_SUITE(node_warnings_tests, BasicTestingSetup)15BOOST_AUTO_TEST_CASE(warnings)16{17node::Warnings warnings;18// On pre-release builds, a warning is generated automatically19warnings.Unset(node::Warning::PRE_RELEASE_TEST_BUILD);21// For these tests, we don't care what the exact warnings are, so22// just refer to them as warning_1 and warning_223const auto warning_1{node::Warning::CLOCK_OUT_OF_SYNC};24const auto warning_2{node::Warning::FATAL_INTERNAL_ERROR};26// Ensure we start without any warnings27BOOST_CHECK(warnings.GetMessages().size() == 0);28// Add two warnings29BOOST_CHECK(warnings.Set(warning_1, _("warning 1")));30BOOST_CHECK(warnings.Set(warning_2, _("warning 2")));31// Unset the second one32BOOST_CHECK(warnings.Unset(warning_2));33// Since it's already been unset, this should return false34BOOST_CHECK(!warnings.Unset(warning_2));35// We should now be able to set w2 again36BOOST_CHECK(warnings.Set(warning_2, _("warning 2 - revision 1")));37// Setting w2 again should return false since it's already set38BOOST_CHECK(!warnings.Set(warning_2, _("warning 2 - revision 2")));40// Verify messages are correct41const auto messages{warnings.GetMessages()};42BOOST_CHECK(messages.size() == 2);43BOOST_CHECK(messages[0].original == "warning 1");44BOOST_CHECK(messages[1].original == "warning 2 - revision 1");46// Clearing all warnings should also clear all messages47BOOST_CHECK(warnings.Unset(warning_1));48BOOST_CHECK(warnings.Unset(warning_2));49BOOST_CHECK(warnings.GetMessages().size() == 0);50}52BOOST_AUTO_TEST_SUITE_END()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.