Bitcoin Core  0.20.99
P2P Digital Currency
init_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2018-2019 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 <boost/test/unit_test.hpp>
6 
7 #include <noui.h>
8 #include <test/util/logging.h>
9 #include <test/util/setup_common.h>
10 #include <util/system.h>
12 
14 
15 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
16 {
17  SetWalletDir(m_walletdir_path_cases["default"]);
18  bool result = m_wallet_client->verify();
19  BOOST_CHECK(result == true);
20  fs::path walletdir = gArgs.GetArg("-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 {
27  SetWalletDir(m_walletdir_path_cases["custom"]);
28  bool result = m_wallet_client->verify();
29  BOOST_CHECK(result == true);
30  fs::path walletdir = gArgs.GetArg("-walletdir", "");
31  fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]);
32  BOOST_CHECK(walletdir == expected_path);
33 }
34 
35 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
36 {
37  SetWalletDir(m_walletdir_path_cases["nonexistent"]);
38  {
39  ASSERT_DEBUG_LOG("does not exist");
40  bool result = m_wallet_client->verify();
41  BOOST_CHECK(result == false);
42  }
43 }
44 
45 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
46 {
47  SetWalletDir(m_walletdir_path_cases["file"]);
48  {
49  ASSERT_DEBUG_LOG("is not a directory");
50  bool result = m_wallet_client->verify();
51  BOOST_CHECK(result == false);
52  }
53 }
54 
55 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
56 {
57  SetWalletDir(m_walletdir_path_cases["relative"]);
58  {
59  ASSERT_DEBUG_LOG("is a relative path");
60  bool result = m_wallet_client->verify();
61  BOOST_CHECK(result == false);
62  }
63 }
64 
65 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
66 {
67  SetWalletDir(m_walletdir_path_cases["trailing"]);
68  bool result = m_wallet_client->verify();
69  BOOST_CHECK(result == true);
70  fs::path walletdir = gArgs.GetArg("-walletdir", "");
71  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
72  BOOST_CHECK(walletdir == expected_path);
73 }
74 
75 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
76 {
77  SetWalletDir(m_walletdir_path_cases["trailing2"]);
78  bool result = m_wallet_client->verify();
79  BOOST_CHECK(result == true);
80  fs::path walletdir = gArgs.GetArg("-walletdir", "");
81  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
82  BOOST_CHECK(walletdir == expected_path);
83 }
84 
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
Definition: init_tests.cpp:15
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:458
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
ArgsManager gArgs
Definition: system.cpp:76
#define BOOST_CHECK(expr)
Definition: object.cpp:17