Bitcoin Core 28.99.0
P2P Digital Currency
init_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2018-2022 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 <common/args.h>
8#include <noui.h>
9#include <test/util/logging.h>
12
13namespace wallet {
14BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup)
15
16BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
17{
18 SetWalletDir(m_walletdir_path_cases["default"]);
19 bool result = m_wallet_loader->verify();
20 BOOST_CHECK(result == true);
21 fs::path walletdir = m_args.GetPathArg("-walletdir");
22 fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
23 BOOST_CHECK_EQUAL(walletdir, expected_path);
24}
25
26BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
27{
28 SetWalletDir(m_walletdir_path_cases["custom"]);
29 bool result = m_wallet_loader->verify();
30 BOOST_CHECK(result == true);
31 fs::path walletdir = m_args.GetPathArg("-walletdir");
32 fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]);
33 BOOST_CHECK_EQUAL(walletdir, expected_path);
34}
35
36BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
37{
38 SetWalletDir(m_walletdir_path_cases["nonexistent"]);
39 {
40 ASSERT_DEBUG_LOG("does not exist");
41 bool result = m_wallet_loader->verify();
42 BOOST_CHECK(result == false);
43 }
44}
45
46BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
47{
48 SetWalletDir(m_walletdir_path_cases["file"]);
49 {
50 ASSERT_DEBUG_LOG("is not a directory");
51 bool result = m_wallet_loader->verify();
52 BOOST_CHECK(result == false);
53 }
54}
55
56BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
57{
58 SetWalletDir(m_walletdir_path_cases["relative"]);
59 {
60 ASSERT_DEBUG_LOG("is a relative path");
61 bool result = m_wallet_loader->verify();
62 BOOST_CHECK(result == false);
63 }
64}
65
66BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
67{
68 SetWalletDir(m_walletdir_path_cases["trailing"]);
69 bool result = m_wallet_loader->verify();
70 BOOST_CHECK(result == true);
71 fs::path walletdir = m_args.GetPathArg("-walletdir");
72 fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
73 BOOST_CHECK_EQUAL(walletdir, expected_path);
74}
75
76BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
77{
78 SetWalletDir(m_walletdir_path_cases["trailing2"]);
79 bool result = m_wallet_loader->verify();
80 BOOST_CHECK(result == true);
81 fs::path walletdir = m_args.GetPathArg("-walletdir");
82 fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
83 BOOST_CHECK_EQUAL(walletdir, expected_path);
84}
85
87} // namespace wallet
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:33
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(bnb_search_test)
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
#define BOOST_CHECK(expr)
Definition: object.cpp:17
#define ASSERT_DEBUG_LOG(message)
Definition: logging.h:39