Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
wallet
test
init_tests.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
5
#include <
common/system.h
>
6
#include <
noui.h
>
7
#include <test/util/logging.h>
8
9
#include <test/util/setup_common.h>
10
#include <
wallet/test/init_test_fixture.h
>
11
12
#include <boost/test/unit_test.hpp>
13
14
BOOST_FIXTURE_TEST_SUITE
(
init_tests
,
InitWalletDirTestingSetup
)
15
16
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_default
) {
17
SetWalletDir(m_walletdir_path_cases[
"default"
]);
18
bool
result = m_wallet_client->verify();
19
BOOST_CHECK
(result ==
true
);
20
fs::path
walletdir
=
gArgs
.
GetPathArg
(
"-walletdir"
);
21
fs::path
expected_path
= fs::canonical(m_walletdir_path_cases[
"default"
]);
22
BOOST_CHECK
(
walletdir
==
expected_path
);
23
}
24
25
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_custom
) {
26
SetWalletDir(m_walletdir_path_cases[
"custom"
]);
27
bool
result = m_wallet_client->verify();
28
BOOST_CHECK
(result ==
true
);
29
fs::path
walletdir
=
gArgs
.
GetPathArg
(
"-walletdir"
);
30
fs::path
expected_path
= fs::canonical(m_walletdir_path_cases[
"custom"
]);
31
BOOST_CHECK
(
walletdir
==
expected_path
);
32
}
33
34
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_does_not_exist
) {
35
SetWalletDir(m_walletdir_path_cases[
"nonexistent"
]);
36
{
37
ASSERT_DEBUG_LOG
(
"does not exist"
);
38
bool
result = m_wallet_client->verify();
39
BOOST_CHECK
(result ==
false
);
40
}
41
}
42
43
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_is_not_directory
) {
44
SetWalletDir(m_walletdir_path_cases[
"file"
]);
45
{
46
ASSERT_DEBUG_LOG
(
"is not a directory"
);
47
bool
result = m_wallet_client->verify();
48
BOOST_CHECK
(result ==
false
);
49
}
50
}
51
52
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_is_not_relative
) {
53
SetWalletDir(m_walletdir_path_cases[
"relative"
]);
54
{
55
ASSERT_DEBUG_LOG
(
"is a relative path"
);
56
bool
result = m_wallet_client->verify();
57
BOOST_CHECK
(result ==
false
);
58
}
59
}
60
61
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_no_trailing
) {
62
SetWalletDir(m_walletdir_path_cases[
"trailing"
]);
63
bool
result = m_wallet_client->verify();
64
BOOST_CHECK
(result ==
true
);
65
fs::path
walletdir
=
gArgs
.
GetPathArg
(
"-walletdir"
);
66
fs::path
expected_path
= fs::canonical(m_walletdir_path_cases[
"default"
]);
67
BOOST_CHECK
(
walletdir
==
expected_path
);
68
}
69
70
BOOST_AUTO_TEST_CASE
(
walletinit_verify_walletdir_no_trailing2
) {
71
SetWalletDir(m_walletdir_path_cases[
"trailing2"
]);
72
bool
result = m_wallet_client->verify();
73
BOOST_CHECK
(result ==
true
);
74
fs::path
walletdir
=
gArgs
.
GetPathArg
(
"-walletdir"
);
75
fs::path
expected_path
= fs::canonical(m_walletdir_path_cases[
"default"
]);
76
BOOST_CHECK
(
walletdir
==
expected_path
);
77
}
78
79
BOOST_AUTO_TEST_SUITE_END
()
gArgs
ArgsManager gArgs
Definition
args.cpp:38
ArgsManager::GetPathArg
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
Definition
args.cpp:275
fs::path
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition
fs.h:30
init_test_fixture.h
noui.h
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition
object.cpp:17
GetRand
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
InitWalletDirTestingSetup
Definition
init_test_fixture.h:13
system.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
Definition
init_tests.cpp:16
Generated on Sat Nov 23 2024 02:38:02 for Bitcoin ABC by
1.9.8