Fabcoin Core  0.16.2
P2P Digital Currency
wallet_test_fixture.cpp
Go to the documentation of this file.
1 // Copyright (c)2016-2017 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 
6 
7 #include <rpc/server.h>
8 #include <wallet/db.h>
9 #include <wallet/wallet.h>
10 
12 
13 WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
14  TestingSetup(chainName)
15 {
16  bitdb.MakeMock();
17 
18  bool fFirstRun;
19  std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
20  pwalletMain = new CWallet(std::move(dbw));
21  pwalletMain->LoadWallet(fFirstRun);
22  RegisterValidationInterface(pwalletMain);
23 
25 }
26 
28 {
29  UnregisterValidationInterface(pwalletMain);
30  delete pwalletMain;
31  pwalletMain = nullptr;
32 
33  bitdb.Flush(true);
34  bitdb.Reset();
35 }
CWallet * pwalletMain
void Reset()
Definition: db.cpp:76
void Flush(bool fShutdown)
Definition: db.cpp:598
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
CDBEnv bitdb
Definition: db.cpp:61
void MakeMock()
Definition: db.cpp:148
CRPCTable tableRPC
Definition: server.cpp:599
An instance of this class represents one database.
Definition: db.h:93
DBErrors LoadWallet(bool &fFirstRunRet)
Definition: wallet.cpp:3175
void RegisterWalletRPCCommands(CRPCTable &t)
Definition: rpcwallet.cpp:3705
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:672
WalletTestingSetup(const std::string &chainName=CBaseChainParams::MAIN)