LCOV - code coverage report
Current view: top level - src/wallet/test - init_tests.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 100.0 % 56 56
Test Date: 2024-08-28 04:44:32 Functions: 100.0 % 14 14
Branches: 50.0 % 544 272

             Branch data     Line data    Source code
       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>
      10                 :             : #include <test/util/setup_common.h>
      11                 :             : #include <wallet/test/init_test_fixture.h>
      12                 :             : 
      13                 :             : namespace wallet {
      14                 :             : BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup)
      15                 :             : 
      16   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      17                 :             : {
      18   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["default"]);
      19                 :           1 :     bool result = m_wallet_loader->verify();
      20         [ +  - ]:           2 :     BOOST_CHECK(result == true);
      21   [ +  -  +  - ]:           2 :     fs::path walletdir = m_args.GetPathArg("-walletdir");
      22   [ +  -  +  -  :           3 :     fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
                   +  - ]
      23   [ +  -  +  - ]:           1 :     BOOST_CHECK_EQUAL(walletdir, expected_path);
      24                 :           2 : }
      25                 :             : 
      26   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      27                 :             : {
      28   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["custom"]);
      29                 :           1 :     bool result = m_wallet_loader->verify();
      30         [ +  - ]:           2 :     BOOST_CHECK(result == true);
      31   [ +  -  +  - ]:           2 :     fs::path walletdir = m_args.GetPathArg("-walletdir");
      32   [ +  -  +  -  :           3 :     fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]);
                   +  - ]
      33   [ +  -  +  - ]:           1 :     BOOST_CHECK_EQUAL(walletdir, expected_path);
      34                 :           2 : }
      35                 :             : 
      36   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      37                 :             : {
      38   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["nonexistent"]);
      39                 :           1 :     {
      40   [ +  -  +  - ]:           2 :         ASSERT_DEBUG_LOG("does not exist");
      41         [ +  - ]:           1 :         bool result = m_wallet_loader->verify();
      42   [ +  -  +  - ]:           2 :         BOOST_CHECK(result == false);
      43                 :           1 :     }
      44                 :           1 : }
      45                 :             : 
      46   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      47                 :             : {
      48   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["file"]);
      49                 :           1 :     {
      50   [ +  -  +  - ]:           2 :         ASSERT_DEBUG_LOG("is not a directory");
      51         [ +  - ]:           1 :         bool result = m_wallet_loader->verify();
      52   [ +  -  +  - ]:           2 :         BOOST_CHECK(result == false);
      53                 :           1 :     }
      54                 :           1 : }
      55                 :             : 
      56   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      57                 :             : {
      58   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["relative"]);
      59                 :           1 :     {
      60   [ +  -  +  - ]:           2 :         ASSERT_DEBUG_LOG("is a relative path");
      61         [ +  - ]:           1 :         bool result = m_wallet_loader->verify();
      62   [ +  -  +  - ]:           2 :         BOOST_CHECK(result == false);
      63                 :           1 :     }
      64                 :           1 : }
      65                 :             : 
      66   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      67                 :             : {
      68   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["trailing"]);
      69                 :           1 :     bool result = m_wallet_loader->verify();
      70         [ +  - ]:           2 :     BOOST_CHECK(result == true);
      71   [ +  -  +  - ]:           2 :     fs::path walletdir = m_args.GetPathArg("-walletdir");
      72   [ +  -  +  -  :           3 :     fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
                   +  - ]
      73   [ +  -  +  - ]:           1 :     BOOST_CHECK_EQUAL(walletdir, expected_path);
      74                 :           2 : }
      75                 :             : 
      76   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      77                 :             : {
      78   [ +  -  +  - ]:           1 :     SetWalletDir(m_walletdir_path_cases["trailing2"]);
      79                 :           1 :     bool result = m_wallet_loader->verify();
      80         [ +  - ]:           2 :     BOOST_CHECK(result == true);
      81   [ +  -  +  - ]:           2 :     fs::path walletdir = m_args.GetPathArg("-walletdir");
      82   [ +  -  +  -  :           3 :     fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
                   +  - ]
      83   [ +  -  +  -  :           1 :     BOOST_CHECK_EQUAL(walletdir, expected_path);
                   +  - ]
      84                 :           2 : }
      85                 :             : 
      86                 :             : BOOST_AUTO_TEST_SUITE_END()
      87                 :             : } // namespace wallet
        

Generated by: LCOV version 2.0-1