Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_test_fixture.cpp
// Copyright (c) 2016 The Bitcoin Core developers | // Copyright (c) 2016 The Bitcoin Core 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 <wallet/test/wallet_test_fixture.h> | #include <wallet/test/wallet_test_fixture.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <wallet/db.h> | #include <wallet/db.h> | ||||
#include <wallet/rpcdump.h> | #include <wallet/rpcdump.h> | ||||
#include <wallet/wallet.h> | |||||
WalletTestingSetup::WalletTestingSetup(const std::string &chainName) | WalletTestingSetup::WalletTestingSetup(const std::string &chainName) | ||||
: TestingSetup(chainName) { | : TestingSetup(chainName), | ||||
bitdb.MakeMock(); | m_wallet(Params(), "mock", CWalletDBWrapper::CreateMock()) { | ||||
bool fFirstRun; | bool fFirstRun; | ||||
std::unique_ptr<CWalletDBWrapper> dbw( | m_wallet.LoadWallet(fFirstRun); | ||||
new CWalletDBWrapper(&bitdb, "wallet_test.dat")); | RegisterValidationInterface(&m_wallet); | ||||
pwalletMain = std::make_unique<CWallet>(Params(), std::move(dbw)); | |||||
pwalletMain->LoadWallet(fFirstRun); | |||||
RegisterValidationInterface(pwalletMain.get()); | |||||
RegisterWalletRPCCommands(tableRPC); | RegisterWalletRPCCommands(tableRPC); | ||||
RegisterDumpRPCCommands(tableRPC); | RegisterDumpRPCCommands(tableRPC); | ||||
} | } | ||||
WalletTestingSetup::~WalletTestingSetup() { | WalletTestingSetup::~WalletTestingSetup() { | ||||
UnregisterValidationInterface(pwalletMain.get()); | UnregisterValidationInterface(&m_wallet); | ||||
bitdb.Flush(true); | |||||
bitdb.Reset(); | |||||
} | } |