Bitcoin ABC  0.22.12
P2P Digital Currency
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 <chainparams.h>
6 #include <noui.h>
7 #include <test/util/logging.h>
8 #include <util/system.h>
9 
10 #include <test/util/setup_common.h>
12 
13 #include <boost/test/unit_test.hpp>
14 
16 
17 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default) {
18  SetWalletDir(m_walletdir_path_cases["default"]);
19  bool result = m_chain_client->verify(Params());
20  BOOST_CHECK(result == true);
21  fs::path walletdir = gArgs.GetArg("-walletdir", "");
22  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
23  BOOST_CHECK(walletdir == expected_path);
24 }
25 
26 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom) {
27  SetWalletDir(m_walletdir_path_cases["custom"]);
28  bool result = m_chain_client->verify(Params());
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  SetWalletDir(m_walletdir_path_cases["nonexistent"]);
37  {
38  ASSERT_DEBUG_LOG("does not exist");
39  bool result = m_chain_client->verify(Params());
40  BOOST_CHECK(result == false);
41  }
42 }
43 
44 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory) {
45  SetWalletDir(m_walletdir_path_cases["file"]);
46  {
47  ASSERT_DEBUG_LOG("is not a directory");
48  bool result = m_chain_client->verify(Params());
49  BOOST_CHECK(result == false);
50  }
51 }
52 
53 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative) {
54  SetWalletDir(m_walletdir_path_cases["relative"]);
55  {
56  ASSERT_DEBUG_LOG("is a relative path");
57  bool result = m_chain_client->verify(Params());
58  BOOST_CHECK(result == false);
59  }
60 }
61 
62 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing) {
63  SetWalletDir(m_walletdir_path_cases["trailing"]);
64  bool result = m_chain_client->verify(Params());
65  BOOST_CHECK(result == true);
66  fs::path walletdir = gArgs.GetArg("-walletdir", "");
67  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
68  BOOST_CHECK(walletdir == expected_path);
69 }
70 
71 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2) {
72  SetWalletDir(m_walletdir_path_cases["trailing2"]);
73  bool result = m_chain_client->verify(Params());
74  BOOST_CHECK(result == true);
75  fs::path walletdir = gArgs.GetArg("-walletdir", "");
76  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
77  BOOST_CHECK(walletdir == expected_path);
78 }
79 
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
Definition: init_tests.cpp:17
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
const CChainParams & Params()
Return the currently selected parameters.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:479
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
ArgsManager gArgs
Definition: system.cpp:76
#define BOOST_CHECK(expr)
Definition: object.cpp:17