|
| 1 | +// Copyright (c) 2018 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 <test/test_bitcoin.h> |
| 8 | +#include <wallet/test/init_test_fixture.h> |
| 9 | + |
| 10 | +#include <init.h> |
| 11 | +#include <walletinitinterface.h> |
| 12 | +#include <wallet/wallet.h> |
| 13 | + |
| 14 | + |
| 15 | +BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup) |
| 16 | + |
| 17 | +BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default) |
| 18 | +{ |
| 19 | + SetWalletDir(m_walletdir_path_cases["default"]); |
| 20 | + bool result = g_wallet_init_interface.Verify(); |
| 21 | + BOOST_CHECK(result == true); |
| 22 | + fs::path walletdir = gArgs.GetArg("-walletdir", ""); |
| 23 | + fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]); |
| 24 | + BOOST_CHECK(walletdir == expected_path); |
| 25 | +} |
| 26 | + |
| 27 | +BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom) |
| 28 | +{ |
| 29 | + SetWalletDir(m_walletdir_path_cases["custom"]); |
| 30 | + bool result = g_wallet_init_interface.Verify(); |
| 31 | + BOOST_CHECK(result == true); |
| 32 | + fs::path walletdir = gArgs.GetArg("-walletdir", ""); |
| 33 | + fs::path expected_path = fs::canonical(m_walletdir_path_cases["custom"]); |
| 34 | + BOOST_CHECK(walletdir == expected_path); |
| 35 | +} |
| 36 | + |
| 37 | +BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist) |
| 38 | +{ |
| 39 | + SetWalletDir(m_walletdir_path_cases["nonexistent"]); |
| 40 | + bool result = g_wallet_init_interface.Verify(); |
| 41 | + BOOST_CHECK(result == false); |
| 42 | +} |
| 43 | + |
| 44 | +BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory) |
| 45 | +{ |
| 46 | + SetWalletDir(m_walletdir_path_cases["file"]); |
| 47 | + bool result = g_wallet_init_interface.Verify(); |
| 48 | + BOOST_CHECK(result == false); |
| 49 | +} |
| 50 | + |
| 51 | +BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative) |
| 52 | +{ |
| 53 | + SetWalletDir(m_walletdir_path_cases["relative"]); |
| 54 | + bool result = g_wallet_init_interface.Verify(); |
| 55 | + BOOST_CHECK(result == false); |
| 56 | +} |
| 57 | + |
| 58 | +BOOST_AUTO_TEST_SUITE_END() |
0 commit comments