Bitcoin ABC 0.30.7
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 <common/system.h>
6#include <noui.h>
7#include <test/util/logging.h>
8
9#include <test/util/setup_common.h>
11
12#include <boost/test/unit_test.hpp>
13
14BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup)
15
16BOOST_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
25BOOST_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
34BOOST_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
43BOOST_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
52BOOST_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
61BOOST_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
70BOOST_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
79BOOST_AUTO_TEST_SUITE_END()
ArgsManager gArgs
Definition: args.cpp:38
BOOST_AUTO_TEST_CASE(avalanche_flag_tests)
Definition: init_tests.cpp:20
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
Definition: args.cpp:275
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
#define BOOST_CHECK(expr)
Definition: object.cpp:17