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 "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" | #include "wallet/wallet.h" | ||||
CWallet *pwalletMain; | CWallet *pwalletMain; | ||||
WalletTestingSetup::WalletTestingSetup(const std::string &chainName) | WalletTestingSetup::WalletTestingSetup(const std::string &chainName) | ||||
: TestingSetup(chainName) { | : TestingSetup(chainName) { | ||||
bitdb.MakeMock(); | bitdb.MakeMock(); | ||||
bool fFirstRun; | bool fFirstRun; | ||||
std::unique_ptr<CWalletDBWrapper> dbw( | std::unique_ptr<CWalletDBWrapper> dbw( | ||||
new CWalletDBWrapper(&bitdb, "wallet_test.dat")); | new CWalletDBWrapper(&bitdb, "wallet_test.dat")); | ||||
pwalletMain = new CWallet(std::move(dbw)); | pwalletMain = new CWallet(Params(), std::move(dbw)); | ||||
pwalletMain->LoadWallet(fFirstRun); | pwalletMain->LoadWallet(fFirstRun); | ||||
RegisterValidationInterface(pwalletMain); | RegisterValidationInterface(pwalletMain); | ||||
RegisterWalletRPCCommands(tableRPC); | RegisterWalletRPCCommands(tableRPC); | ||||
RegisterDumpRPCCommands(tableRPC); | RegisterDumpRPCCommands(tableRPC); | ||||
} | } | ||||
WalletTestingSetup::~WalletTestingSetup() { | WalletTestingSetup::~WalletTestingSetup() { | ||||
UnregisterValidationInterface(pwalletMain); | UnregisterValidationInterface(pwalletMain); | ||||
delete pwalletMain; | delete pwalletMain; | ||||
pwalletMain = nullptr; | pwalletMain = nullptr; | ||||
bitdb.Flush(true); | bitdb.Flush(true); | ||||
bitdb.Reset(); | bitdb.Reset(); | ||||
} | } |