LCOV - code coverage report
Current view: top level - src/wallet/test - init_test_fixture.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 27 28 96.4 %
Date: 2020-09-26 01:30:44 Functions: 4 6 66.7 %

          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 <fs.h>
       6             : #include <util/check.h>
       7             : #include <util/system.h>
       8             : 
       9             : #include <wallet/test/init_test_fixture.h>
      10             : 
      11           7 : InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
      12           7 : {
      13          14 :     m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args), {});
      14             : 
      15           7 :     std::string sep;
      16           7 :     sep += fs::path::preferred_separator;
      17             : 
      18           7 :     m_datadir = GetDataDir();
      19           7 :     m_cwd = fs::current_path();
      20             : 
      21           7 :     m_walletdir_path_cases["default"] = m_datadir / "wallets";
      22          14 :     m_walletdir_path_cases["custom"] = m_datadir / "my_wallets";
      23           7 :     m_walletdir_path_cases["nonexistent"] = m_datadir / "path_does_not_exist";
      24           7 :     m_walletdir_path_cases["file"] = m_datadir / "not_a_directory.dat";
      25           7 :     m_walletdir_path_cases["trailing"] = m_datadir / "wallets" / sep;
      26           7 :     m_walletdir_path_cases["trailing2"] = m_datadir / "wallets" / sep / sep;
      27             : 
      28           7 :     fs::current_path(m_datadir);
      29           7 :     m_walletdir_path_cases["relative"] = "wallets";
      30             : 
      31           7 :     fs::create_directories(m_walletdir_path_cases["default"]);
      32           7 :     fs::create_directories(m_walletdir_path_cases["custom"]);
      33           7 :     fs::create_directories(m_walletdir_path_cases["relative"]);
      34           7 :     std::ofstream f(m_walletdir_path_cases["file"].BOOST_FILESYSTEM_C_STR);
      35           7 :     f.close();
      36           7 : }
      37             : 
      38           7 : InitWalletDirTestingSetup::~InitWalletDirTestingSetup()
      39           0 : {
      40           7 :     fs::current_path(m_cwd);
      41           7 : }
      42             : 
      43           7 : void InitWalletDirTestingSetup::SetWalletDir(const fs::path& walletdir_path)
      44             : {
      45           7 :     gArgs.ForceSetArg("-walletdir", walletdir_path.string());
      46           7 : }

Generated by: LCOV version 1.15