Bitcoin Core
31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
wallet
test
init_test_fixture.cpp
Go to the documentation of this file.
1
// Copyright (c) 2018-present 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
5
#include <
common/args.h
>
6
#include <
univalue.h
>
7
#include <
util/chaintype.h
>
8
#include <
util/check.h
>
9
#include <
util/fs.h
>
10
11
#include <fstream>
12
#include <string>
13
14
#include <
wallet/test/init_test_fixture.h
>
15
16
namespace
wallet
{
17
InitWalletDirTestingSetup::InitWalletDirTestingSetup
(
const
ChainType
chainType
) :
BasicTestingSetup
(
chainType
)
18
{
19
m_wallet_loader
= MakeWalletLoader(*
m_node
.
chain
,
m_args
);
20
21
const
auto
sep
= fs::path::preferred_separator;
22
23
m_datadir
=
m_args
.
GetDataDirNet
();
24
m_cwd
= fs::current_path();
25
26
m_walletdir_path_cases
[
"default"
] =
m_datadir
/
"wallets"
;
27
m_walletdir_path_cases
[
"custom"
] =
m_datadir
/
"my_wallets"
;
28
m_walletdir_path_cases
[
"nonexistent"
] =
m_datadir
/
"path_does_not_exist"
;
29
m_walletdir_path_cases
[
"file"
] =
m_datadir
/
"not_a_directory.dat"
;
30
m_walletdir_path_cases
[
"trailing"
] = (
m_datadir
/
"wallets"
) +
sep
;
31
m_walletdir_path_cases
[
"trailing2"
] = (
m_datadir
/
"wallets"
) +
sep
+
sep
;
32
33
fs::current_path(
m_datadir
);
34
m_walletdir_path_cases
[
"relative"
] =
"wallets"
;
35
36
fs::create_directories(
m_walletdir_path_cases
[
"default"
]);
37
fs::create_directories(
m_walletdir_path_cases
[
"custom"
]);
38
fs::create_directories(
m_walletdir_path_cases
[
"relative"
]);
39
std::ofstream
f
{
m_walletdir_path_cases
[
"file"
].std_path()};
40
f
.close();
41
}
42
43
InitWalletDirTestingSetup::~InitWalletDirTestingSetup
()
44
{
45
fs::current_path(
m_cwd
);
46
}
47
48
void
InitWalletDirTestingSetup::SetWalletDir
(
const
fs::path&
walletdir_path
)
49
{
50
m_args
.
ForceSetArg
(
"-walletdir"
,
fs::PathToString
(
walletdir_path
));
51
}
52
}
// namespace wallet
args.h
chaintype.h
ChainType
ChainType
Definition
chaintype.h:11
check.h
ArgsManager::ForceSetArg
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition
args.cpp:571
ArgsManager::GetDataDirNet
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
Definition
args.h:239
fs.h
std::filesystem::PathToString
static std::string PathToString(const path &path)
Convert path object to a byte string.
Definition
fs.h:157
init_test_fixture.h
wallet
Definition
wallet_balance.cpp:26
BasicTestingSetup
Basic testing setup.
Definition
setup_common.h:64
BasicTestingSetup::m_args
ArgsManager m_args
Test-specific arguments and settings.
Definition
setup_common.h:99
BasicTestingSetup::m_node
node::NodeContext m_node
Definition
setup_common.h:66
node::NodeContext::chain
std::unique_ptr< interfaces::Chain > chain
Definition
context.h:76
wallet::InitWalletDirTestingSetup::~InitWalletDirTestingSetup
~InitWalletDirTestingSetup()
Definition
init_test_fixture.cpp:43
wallet::InitWalletDirTestingSetup::m_walletdir_path_cases
std::map< std::string, fs::path > m_walletdir_path_cases
Definition
init_test_fixture.h:23
wallet::InitWalletDirTestingSetup::m_wallet_loader
std::unique_ptr< interfaces::WalletLoader > m_wallet_loader
Definition
init_test_fixture.h:24
wallet::InitWalletDirTestingSetup::m_datadir
fs::path m_datadir
Definition
init_test_fixture.h:21
wallet::InitWalletDirTestingSetup::InitWalletDirTestingSetup
InitWalletDirTestingSetup(ChainType chain_type=ChainType::MAIN)
Definition
init_test_fixture.cpp:17
wallet::InitWalletDirTestingSetup::m_cwd
fs::path m_cwd
Definition
init_test_fixture.h:22
wallet::InitWalletDirTestingSetup::SetWalletDir
void SetWalletDir(const fs::path &walletdir_path)
Definition
init_test_fixture.cpp:48
univalue.h
Ticks
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition
time.h:73
Generated on Thu Apr 16 2026 09:42:38 for Bitcoin Core by
1.10.0