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