Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
init_test_fixture.cpp
Go to the documentation of this file.
1// Copyright (c) 2018 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
6
7#include <chainparams.h>
8#include <common/system.h>
9#include <univalue.h>
10#include <util/check.h>
11#include <util/fs.h>
12
13#include <fstream>
14#include <string>
15
17 const std::string &chainName)
18 : BasicTestingSetup(chainName) {
19 m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args));
20
21 std::string sep;
22 sep += fs::path::preferred_separator;
23
25 m_cwd = fs::current_path();
26
27 m_walletdir_path_cases["default"] = m_datadir / "wallets";
28 m_walletdir_path_cases["custom"] = m_datadir / "my_wallets";
29 m_walletdir_path_cases["nonexistent"] = m_datadir / "path_does_not_exist";
30 m_walletdir_path_cases["file"] = m_datadir / "not_a_directory.dat";
31 m_walletdir_path_cases["trailing"] = m_datadir / ("wallets" + sep);
32 m_walletdir_path_cases["trailing2"] = m_datadir / ("wallets" + sep + sep);
33
34 fs::current_path(m_datadir);
35 m_walletdir_path_cases["relative"] = "wallets";
36
40 std::ofstream f{m_walletdir_path_cases["file"]};
41 f.close();
42}
43
46 settings.forced_settings.erase("walletdir");
47 });
48 fs::current_path(m_cwd);
49}
50
ArgsManager gArgs
Definition args.cpp:38
#define Assert(val)
Identity function.
Definition check.h:84
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition args.cpp:597
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
Definition args.h:215
void LockSettings(Fn &&fn)
Access settings with lock held.
Definition args.h:398
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition fs.h:30
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
Definition fs.h:179
static std::string PathToString(const path &path)
Convert path object to byte string.
Definition fs.h:142
NodeContext & m_node
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
std::unique_ptr< interfaces::WalletClient > m_wallet_client
InitWalletDirTestingSetup(const std::string &chainName=CBaseChainParams::MAIN)
std::map< std::string, fs::path > m_walletdir_path_cases
void SetWalletDir(const fs::path &walletdir_path)
Stored settings.
Definition settings.h:31