Merge bitcoin/bitcoin#24841: test: fix connman UB by calling derived constructor

c848a45101 test: fix connman UB by calling derived constructor (chinggg)

Pull request description:

  Hopefully closes #24373 by calling `ConnmanTestMsg` test-constructor to avoid undefined behavior in process_message.cpp after casting `g_setup->m_node.connman`.

Top commit has no ACKs.

Tree-SHA512: c3dce9dcce33614c7b739edf28e416b600ab3d38d16cdb0430490e8ffc9b64aff9292006ae6fe7c636ab0627893bb21f69435893bdfb129a9a865be92baa6f17
This commit is contained in:
MarcoFalke 2022-04-16 09:10:26 +02:00
commit 6be319beb8
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -15,10 +15,10 @@
#include <interfaces/chain.h>
#include <net.h>
#include <net_processing.h>
#include <node/miner.h>
#include <noui.h>
#include <node/blockstorage.h>
#include <node/chainstate.h>
#include <node/miner.h>
#include <noui.h>
#include <policy/fees.h>
#include <pow.h>
#include <rpc/blockchain.h>
@ -28,6 +28,7 @@
#include <script/sigcache.h>
#include <shutdown.h>
#include <streams.h>
#include <test/util/net.h>
#include <txdb.h>
#include <util/strencodings.h>
#include <util/string.h>
@ -226,7 +227,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
/*deterministic=*/false,
m_node.args->GetIntArg("-checkaddrman", 0));
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
m_node.connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman,
m_node.banman.get(), *m_node.chainman,
*m_node.mempool, false);