mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
scripted-diff: Change ArgsManager.GetDataDirPath()
to ArgsManager.GetDataDirBase()
in tests
-BEGIN VERIFY SCRIPT- git ls-files src/test/*_tests.cpp src/test/util/setup_common.cpp | xargs sed -i 's/.GetDataDirPath()/.GetDataDirBase()/g'; -END VERIFY SCRIPT-
This commit is contained in:
parent
0f53df47d5
commit
4d8189f620
@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_obfuscate_true" : "dbwrapper_obfuscate_false");
|
||||
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_obfuscate_true" : "dbwrapper_obfuscate_false");
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
char key = 'k';
|
||||
uint256 in = InsecureRand256();
|
||||
@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_basic_data)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (bool obfuscate : {false, true}) {
|
||||
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_1_obfuscate_true" : "dbwrapper_1_obfuscate_false");
|
||||
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_1_obfuscate_true" : "dbwrapper_1_obfuscate_false");
|
||||
CDBWrapper dbw(ph, (1 << 20), false, true, obfuscate);
|
||||
|
||||
uint256 res;
|
||||
@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_batch_obfuscate_true" : "dbwrapper_batch_obfuscate_false");
|
||||
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_batch_obfuscate_true" : "dbwrapper_batch_obfuscate_false");
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
char key = 'i';
|
||||
@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = m_args.GetDataDirPath() / (obfuscate ? "dbwrapper_iterator_obfuscate_true" : "dbwrapper_iterator_obfuscate_false");
|
||||
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_iterator_obfuscate_true" : "dbwrapper_iterator_obfuscate_false");
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
// The two keys are intentionally chosen for ordering
|
||||
@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||
{
|
||||
// We're going to share this fs::path between two wrappers
|
||||
fs::path ph = m_args.GetDataDirPath() / "existing_data_no_obfuscate";
|
||||
fs::path ph = m_args.GetDataDirBase() / "existing_data_no_obfuscate";
|
||||
create_directories(ph);
|
||||
|
||||
// Set up a non-obfuscated wrapper to write some initial data.
|
||||
@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate)
|
||||
BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||
{
|
||||
// We're going to share this fs::path between two wrappers
|
||||
fs::path ph = m_args.GetDataDirPath() / "existing_data_reindex";
|
||||
fs::path ph = m_args.GetDataDirBase() / "existing_data_reindex";
|
||||
create_directories(ph);
|
||||
|
||||
// Set up a non-obfuscated wrapper to write some initial data.
|
||||
@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(iterator_ordering)
|
||||
{
|
||||
fs::path ph = m_args.GetDataDirPath() / "iterator_ordering";
|
||||
fs::path ph = m_args.GetDataDirBase() / "iterator_ordering";
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, false);
|
||||
for (int x=0x00; x<256; ++x) {
|
||||
uint8_t key = x;
|
||||
@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
|
||||
{
|
||||
char buf[10];
|
||||
|
||||
fs::path ph = m_args.GetDataDirPath() / "iterator_string_ordering";
|
||||
fs::path ph = m_args.GetDataDirBase() / "iterator_string_ordering";
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, false);
|
||||
for (int x=0x00; x<10; ++x) {
|
||||
for (int y = 0; y < 10; y++) {
|
||||
@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(unicodepath)
|
||||
// On Windows this test will fail if the directory is created using
|
||||
// the ANSI CreateDirectoryA call and the code page isn't UTF8.
|
||||
// It will succeed if created with CreateDirectoryW.
|
||||
fs::path ph = m_args.GetDataDirPath() / "test_runner_₿_🏃_20191128_104644";
|
||||
fs::path ph = m_args.GetDataDirBase() / "test_runner_₿_🏃_20191128_104644";
|
||||
CDBWrapper dbw(ph, (1 << 20));
|
||||
|
||||
fs::path lockPath = ph / "LOCK";
|
||||
|
@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
auto banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
auto connman = std::make_unique<CConnmanTest>(0x1337, 0x1337, *m_node.addrman);
|
||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(),
|
||||
*m_node.scheduler, *m_node.chainman, *m_node.mempool, false);
|
||||
@ -302,7 +302,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
auto banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
|
||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(),
|
||||
*m_node.scheduler, *m_node.chainman, *m_node.mempool, false);
|
||||
|
@ -14,7 +14,7 @@ BOOST_FIXTURE_TEST_SUITE(flatfile_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(flatfile_filename)
|
||||
{
|
||||
const auto data_dir = m_args.GetDataDirPath();
|
||||
const auto data_dir = m_args.GetDataDirBase();
|
||||
|
||||
FlatFilePos pos(456, 789);
|
||||
|
||||
@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(flatfile_filename)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(flatfile_open)
|
||||
{
|
||||
const auto data_dir = m_args.GetDataDirPath();
|
||||
const auto data_dir = m_args.GetDataDirBase();
|
||||
FlatFileSeq seq(data_dir, "a", 16 * 1024);
|
||||
|
||||
std::string line1("A purely peer-to-peer version of electronic cash would allow online "
|
||||
@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(flatfile_allocate)
|
||||
{
|
||||
const auto data_dir = m_args.GetDataDirPath();
|
||||
const auto data_dir = m_args.GetDataDirBase();
|
||||
FlatFileSeq seq(data_dir, "a", 100);
|
||||
|
||||
bool out_of_space;
|
||||
@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(flatfile_allocate)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(flatfile_flush)
|
||||
{
|
||||
const auto data_dir = m_args.GetDataDirPath();
|
||||
const auto data_dir = m_args.GetDataDirBase();
|
||||
FlatFileSeq seq(data_dir, "a", 100);
|
||||
|
||||
bool out_of_space;
|
||||
|
@ -13,7 +13,7 @@ BOOST_FIXTURE_TEST_SUITE(fs_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(fsbridge_fstream)
|
||||
{
|
||||
fs::path tmpfolder = m_args.GetDataDirPath();
|
||||
fs::path tmpfolder = m_args.GetDataDirBase();
|
||||
// tmpfile1 should be the same as tmpfile2
|
||||
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
|
||||
fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
|
||||
|
@ -45,7 +45,7 @@ BOOST_FIXTURE_TEST_SUITE(settings_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ReadWrite)
|
||||
{
|
||||
fs::path path = m_args.GetDataDirPath() / "settings.json";
|
||||
fs::path path = m_args.GetDataDirBase() / "settings.json";
|
||||
|
||||
WriteText(path, R"({
|
||||
"string": "string",
|
||||
|
@ -195,7 +195,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||
}
|
||||
|
||||
m_node.addrman = std::make_unique<CAddrMan>();
|
||||
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirPath() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
|
||||
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman,
|
||||
m_node.banman.get(), *m_node.scheduler, *m_node.chainman,
|
||||
|
@ -53,23 +53,23 @@ BOOST_AUTO_TEST_CASE(util_datadir)
|
||||
ArgsManager args;
|
||||
args.ForceSetArg("-datadir", m_path_root.string());
|
||||
|
||||
const fs::path dd_norm = args.GetDataDirPath();
|
||||
const fs::path dd_norm = args.GetDataDirBase();
|
||||
|
||||
args.ForceSetArg("-datadir", dd_norm.string() + "/");
|
||||
args.ClearPathCache();
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||
|
||||
args.ForceSetArg("-datadir", dd_norm.string() + "/.");
|
||||
args.ClearPathCache();
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||
|
||||
args.ForceSetArg("-datadir", dd_norm.string() + "/./");
|
||||
args.ClearPathCache();
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||
|
||||
args.ForceSetArg("-datadir", dd_norm.string() + "/.//");
|
||||
args.ClearPathCache();
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirPath());
|
||||
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_check)
|
||||
@ -1159,10 +1159,10 @@ BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
|
||||
// Test error logging, and remove previously written setting.
|
||||
{
|
||||
ASSERT_DEBUG_LOG("Failed renaming settings file");
|
||||
fs::remove(args1.GetDataDirPath() / "settings.json");
|
||||
fs::create_directory(args1.GetDataDirPath() / "settings.json");
|
||||
fs::remove(args1.GetDataDirBase() / "settings.json");
|
||||
fs::create_directory(args1.GetDataDirBase() / "settings.json");
|
||||
args2.WriteSettingsFile();
|
||||
fs::remove(args1.GetDataDirPath() / "settings.json");
|
||||
fs::remove(args1.GetDataDirBase() / "settings.json");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1810,7 +1810,7 @@ static constexpr char ExitCommand = 'X';
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_LockDirectory)
|
||||
{
|
||||
fs::path dirname = m_args.GetDataDirPath() / "lock_dir";
|
||||
fs::path dirname = m_args.GetDataDirBase() / "lock_dir";
|
||||
const std::string lockname = ".lock";
|
||||
#ifndef WIN32
|
||||
// Revert SIGCHLD to default, otherwise boost.test will catch and fail on
|
||||
@ -1899,7 +1899,7 @@ BOOST_AUTO_TEST_CASE(test_LockDirectory)
|
||||
BOOST_AUTO_TEST_CASE(test_DirIsWritable)
|
||||
{
|
||||
// Should be able to write to the data dir.
|
||||
fs::path tmpdirname = m_args.GetDataDirPath();
|
||||
fs::path tmpdirname = m_args.GetDataDirBase();
|
||||
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true);
|
||||
|
||||
// Should not be able to write to a non-existent dir.
|
||||
|
Loading…
Reference in New Issue
Block a user