Skip to content

Commit 511ce3a

Browse files
committed
BasicTestingSetup: Add ArgsManager.
1 parent 1cb52ba commit 511ce3a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/test/util/setup_common.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
7171
}
7272

7373
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
74-
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()}
74+
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
75+
m_args{}
7576
{
7677
const std::vector<const char*> arguments = Cat(
7778
{
@@ -87,6 +88,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
8788
extra_args);
8889
util::ThreadRename("test");
8990
fs::create_directories(m_path_root);
91+
m_args.ForceSetArg("-datadir", m_path_root.string());
9092
gArgs.ForceSetArg("-datadir", m_path_root.string());
9193
ClearDatadirCache();
9294
{
@@ -191,7 +193,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
191193
}
192194

193195
m_node.addrman = std::make_unique<CAddrMan>();
194-
m_node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
196+
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
195197
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
196198
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman,
197199
m_node.banman.get(), *m_node.scheduler, *m_node.chainman,

src/test/util/setup_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <chainparamsbase.h>
99
#include <fs.h>
1010
#include <key.h>
11+
#include <util/system.h>
1112
#include <node/context.h>
1213
#include <pubkey.h>
1314
#include <random.h>
@@ -80,6 +81,7 @@ struct BasicTestingSetup {
8081
~BasicTestingSetup();
8182

8283
const fs::path m_path_root;
84+
ArgsManager m_args;
8385
};
8486

8587
/** Testing setup that performs all steps up until right before

0 commit comments

Comments
 (0)