BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
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 <boost/test/unit_test.hpp>
6 
7 #include <test/test_bitcoin.h>
9 
10 #include <init.h>
11 #include <walletinitinterface.h>
12 #include <wallet/wallet.h>
13 
14 
16 
17 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
18 {
19  SetWalletDir(m_walletdir_path_cases["default"]);
20  bool result = g_wallet_init_interface.Verify();
21  BOOST_CHECK(result == true);
22  fs::path walletdir = gArgs.GetArg("-walletdir", "");
23  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
24  BOOST_CHECK(walletdir == expected_path);
25 }
26 
27 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
28 {
29  SetWalletDir(m_walletdir_path_cases["custom"]);
30  bool result = g_wallet_init_interface.Verify();
31  BOOST_CHECK(result == true);
32  fs::path walletdir = gArgs.GetArg("-walletdir", "");
33  fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]);
34  BOOST_CHECK(walletdir == expected_path);
35 }
36 
37 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
38 {
39  SetWalletDir(m_walletdir_path_cases["nonexistent"]);
40  bool result = g_wallet_init_interface.Verify();
41  BOOST_CHECK(result == false);
42 }
43 
44 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
45 {
46  SetWalletDir(m_walletdir_path_cases["file"]);
47  bool result = g_wallet_init_interface.Verify();
48  BOOST_CHECK(result == false);
49 }
50 
51 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
52 {
53  SetWalletDir(m_walletdir_path_cases["relative"]);
54  bool result = g_wallet_init_interface.Verify();
55  BOOST_CHECK(result == false);
56 }
57 
58 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
59 {
60  SetWalletDir(m_walletdir_path_cases["trailing"]);
61  bool result = g_wallet_init_interface.Verify();
62  BOOST_CHECK(result == true);
63  fs::path walletdir = gArgs.GetArg("-walletdir", "");
64  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
65  BOOST_CHECK(walletdir == expected_path);
66 }
67 
68 BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
69 {
70  SetWalletDir(m_walletdir_path_cases["trailing2"]);
71  bool result = g_wallet_init_interface.Verify();
72  BOOST_CHECK(result == true);
73  fs::path walletdir = gArgs.GetArg("-walletdir", "");
74  fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
75  BOOST_CHECK(walletdir == expected_path);
76 }
77 
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
Definition: init_tests.cpp:17
virtual bool Verify() const =0
Verify wallets.
const WalletInitInterface & g_wallet_init_interface
Definition: dummywallet.cpp:35
ArgsManager gArgs
Definition: util.cpp:88
#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: util.cpp:526
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
#define BOOST_CHECK(expr)
Definition: object.cpp:17