LCOV - code coverage report
Current view: top level - src/wallet/test - init_tests.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 55 55 100.0 %
Date: 2020-09-26 01:30:44 Functions: 51 51 100.0 %

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

Generated by: LCOV version 1.15