Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/walletdb_tests.cpp
// Copyright (c) 2017 The Bitcoin developers | // Copyright (c) 2017 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "chainparams.h" | |||||
#include "test/test_bitcoin.h" | #include "test/test_bitcoin.h" | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
#include "wallet/walletdb.h" | #include "wallet/walletdb.h" | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
namespace { | namespace { | ||||
Show All 16 Lines | BOOST_CHECK_MESSAGE(fs::create_directory(dir), | ||||
"Unable to create a directory for test " + testname); | "Unable to create a directory for test " + testname); | ||||
fs::path path = | fs::path path = | ||||
dir / strprintf("testwallet%i", static_cast<int>(GetRand(1000000))); | dir / strprintf("testwallet%i", static_cast<int>(GetRand(1000000))); | ||||
return std::unique_ptr<CWalletDBWrapper>( | return std::unique_ptr<CWalletDBWrapper>( | ||||
new CWalletDBWrapper(&bitdb, path.string())); | new CWalletDBWrapper(&bitdb, path.string())); | ||||
} | } | ||||
static std::unique_ptr<CWallet> LoadWallet(CWalletDB *db) { | static std::unique_ptr<CWallet> LoadWallet(CWalletDB *db) { | ||||
std::unique_ptr<CWallet> wallet(new CWallet); | std::unique_ptr<CWallet> wallet(new CWallet(Params())); | ||||
DBErrors res = db->LoadWallet(wallet.get()); | DBErrors res = db->LoadWallet(wallet.get()); | ||||
BOOST_CHECK(res == DB_LOAD_OK); | BOOST_CHECK(res == DB_LOAD_OK); | ||||
return wallet; | return wallet; | ||||
} | } | ||||
} // namespace | } // namespace | ||||
BOOST_FIXTURE_TEST_SUITE(walletdb_tests, WalletDBTestingSetup); | BOOST_FIXTURE_TEST_SUITE(walletdb_tests, WalletDBTestingSetup); | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |