Bitcoin ABC  0.26.3
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 <noui.h>
6 #include <test/util/logging.h>
7 #include <util/system.h>
8 
9 #include <test/util/setup_common.h>
11 
12 #include <boost/test/unit_test.hpp>
13 
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 = fs::PathFromString(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  SetWalletDir(m_walletdir_path_cases["custom"]);
27  bool result = m_wallet_client->verify();
28  BOOST_CHECK(result == true);
29  fs::path walletdir = fs::PathFromString(gArgs.GetArg("-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 = fs::PathFromString(gArgs.GetArg("-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 = fs::PathFromString(gArgs.GetArg("-walletdir", ""));
75  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
76  BOOST_CHECK(walletdir == expected_path);
77 }
78 
BOOST_AUTO_TEST_CASE(avalanche_flag_tests)
Definition: init_tests.cpp:20
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:584
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
Definition: fs.h:33
static path PathFromString(const std::string &string)
Convert byte string to path object.
Definition: fs.h:147
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK(expr)
Definition: object.cpp:17
ArgsManager gArgs
Definition: system.cpp:77