mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 08:44:02 +02:00
refactor: remove warnings globals
This commit is contained in:
@@ -27,7 +27,7 @@ BOOST_FIXTURE_TEST_SUITE(blockmanager_tests, BasicTestingSetup)
|
||||
BOOST_AUTO_TEST_CASE(blockmanager_find_block_pos)
|
||||
{
|
||||
const auto params {CreateChainParams(ArgsManager{}, ChainType::MAIN)};
|
||||
KernelNotifications notifications{*Assert(m_node.shutdown), m_node.exit_status};
|
||||
KernelNotifications notifications{*Assert(m_node.shutdown), m_node.exit_status, *Assert(m_node.warnings)};
|
||||
const BlockManager::Options blockman_opts{
|
||||
.chainparams = *params,
|
||||
.blocks_dir = m_args.GetBlocksDirPath(),
|
||||
@@ -134,7 +134,7 @@ BOOST_FIXTURE_TEST_CASE(blockmanager_block_data_availability, TestChain100Setup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(blockmanager_flush_block_file)
|
||||
{
|
||||
KernelNotifications notifications{*Assert(m_node.shutdown), m_node.exit_status};
|
||||
KernelNotifications notifications{*Assert(m_node.shutdown), m_node.exit_status, *Assert(m_node.warnings)};
|
||||
node::BlockManager::Options blockman_opts{
|
||||
.chainparams = Params(),
|
||||
.blocks_dir = m_args.GetBlocksDirPath(),
|
||||
|
||||
@@ -141,7 +141,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
{
|
||||
NodeId id{0};
|
||||
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, {});
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
|
||||
constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS;
|
||||
CConnman::Options options;
|
||||
@@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(block_relay_only_eviction)
|
||||
{
|
||||
NodeId id{0};
|
||||
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, {});
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
|
||||
constexpr int max_outbound_block_relay{MAX_BLOCK_RELAY_ONLY_CONNECTIONS};
|
||||
constexpr int64_t MINIMUM_CONNECT_TIME{30};
|
||||
@@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
|
||||
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, banman.get(), *m_node.chainman, *m_node.mempool, {});
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, banman.get(), *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
|
||||
CNetAddr tor_netaddr;
|
||||
BOOST_REQUIRE(
|
||||
@@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
|
||||
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, banman.get(), *m_node.chainman, *m_node.mempool, {});
|
||||
auto peerLogic = PeerManager::make(*connman, *m_node.addrman, banman.get(), *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
|
||||
banman->ClearBanned();
|
||||
int64_t nStartTime = GetTime();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <node/timeoffsets.h>
|
||||
#include <node/warnings.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/util/setup_common.h>
|
||||
@@ -19,7 +20,8 @@ void initialize_timeoffsets()
|
||||
FUZZ_TARGET(timeoffsets, .init = initialize_timeoffsets)
|
||||
{
|
||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
TimeOffsets offsets{};
|
||||
node::Warnings warnings{};
|
||||
TimeOffsets offsets{warnings};
|
||||
LIMITED_WHILE(fuzzed_data_provider.remaining_bytes() > 0, 4'000) {
|
||||
(void)offsets.Median();
|
||||
offsets.Add(std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<std::chrono::seconds::rep>()});
|
||||
|
||||
@@ -84,7 +84,7 @@ static void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman
|
||||
BOOST_AUTO_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection)
|
||||
{
|
||||
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params());
|
||||
auto peerman = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, {});
|
||||
auto peerman = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
NodeId id{0};
|
||||
std::vector<CNode*> nodes;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ static void mineBlock(const node::NodeContext& node, std::chrono::seconds block_
|
||||
// Verifying when network-limited peer connections are desirable based on the node's proximity to the tip
|
||||
BOOST_AUTO_TEST_CASE(connections_desirable_service_flags)
|
||||
{
|
||||
std::unique_ptr<PeerManager> peerman = PeerManager::make(*m_node.connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, {});
|
||||
std::unique_ptr<PeerManager> peerman = PeerManager::make(*m_node.connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {});
|
||||
auto consensus = m_node.chainman->GetParams().GetConsensus();
|
||||
|
||||
// Check we start connecting to full nodes
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//
|
||||
|
||||
#include <node/timeoffsets.h>
|
||||
#include <node/warnings.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@@ -24,7 +25,8 @@ BOOST_FIXTURE_TEST_SUITE(timeoffsets_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(timeoffsets)
|
||||
{
|
||||
TimeOffsets offsets{};
|
||||
node::Warnings warnings{};
|
||||
TimeOffsets offsets{warnings};
|
||||
BOOST_CHECK(offsets.Median() == 0s);
|
||||
|
||||
AddMulti(offsets, {{0s, -1s, -2s, -3s}});
|
||||
@@ -50,7 +52,8 @@ BOOST_AUTO_TEST_CASE(timeoffsets)
|
||||
|
||||
static bool IsWarningRaised(const std::vector<std::chrono::seconds>& check_offsets)
|
||||
{
|
||||
TimeOffsets offsets{};
|
||||
node::Warnings warnings{};
|
||||
TimeOffsets offsets{warnings};
|
||||
AddMulti(offsets, check_offsets);
|
||||
return offsets.WarnIfOutOfSync();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <node/miner.h>
|
||||
#include <node/peerman_args.h>
|
||||
#include <node/validation_cache_args.h>
|
||||
#include <node/warnings.h>
|
||||
#include <noui.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/fees_args.h>
|
||||
@@ -182,6 +183,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto
|
||||
InitLogging(*m_node.args);
|
||||
AppInitParameterInteraction(*m_node.args);
|
||||
LogInstance().StartLogging();
|
||||
m_node.warnings = std::make_unique<node::Warnings>();
|
||||
m_node.kernel = std::make_unique<kernel::Context>();
|
||||
m_node.ecc_context = std::make_unique<ECC_Context>();
|
||||
SetupEnvironment();
|
||||
@@ -230,10 +232,11 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, const std::vecto
|
||||
bilingual_str error{};
|
||||
m_node.mempool = std::make_unique<CTxMemPool>(MemPoolOptionsForTest(m_node), error);
|
||||
Assert(error.empty());
|
||||
m_node.warnings = std::make_unique<node::Warnings>();
|
||||
|
||||
m_cache_sizes = CalculateCacheSizes(m_args);
|
||||
|
||||
m_node.notifications = std::make_unique<KernelNotifications>(*Assert(m_node.shutdown), m_node.exit_status);
|
||||
m_node.notifications = std::make_unique<KernelNotifications>(*Assert(m_node.shutdown), m_node.exit_status, *Assert(m_node.warnings));
|
||||
|
||||
const ChainstateManager::Options chainman_opts{
|
||||
.chainparams = chainparams,
|
||||
@@ -322,7 +325,8 @@ TestingSetup::TestingSetup(
|
||||
peerman_opts.deterministic_rng = true;
|
||||
m_node.peerman = PeerManager::make(*m_node.connman, *m_node.addrman,
|
||||
m_node.banman.get(), *m_node.chainman,
|
||||
*m_node.mempool, peerman_opts);
|
||||
*m_node.mempool, *m_node.warnings,
|
||||
peerman_opts);
|
||||
|
||||
{
|
||||
CConnman::Options options;
|
||||
|
||||
@@ -378,7 +378,7 @@ struct SnapshotTestSetup : TestChain100Setup {
|
||||
LOCK(::cs_main);
|
||||
chainman.ResetChainstates();
|
||||
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 0);
|
||||
m_node.notifications = std::make_unique<KernelNotifications>(*Assert(m_node.shutdown), m_node.exit_status);
|
||||
m_node.notifications = std::make_unique<KernelNotifications>(*Assert(m_node.shutdown), m_node.exit_status, *Assert(m_node.warnings));
|
||||
const ChainstateManager::Options chainman_opts{
|
||||
.chainparams = ::Params(),
|
||||
.datadir = chainman.m_options.datadir,
|
||||
|
||||
Reference in New Issue
Block a user