Raven Core  3.0.0
P2P Digital Currency
wallet_test_fixture.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
7 
8 #include "rpc/server.h"
9 #include "wallet/db.h"
10 #include "wallet/wallet.h"
11 
13 
14 WalletTestingSetup::WalletTestingSetup(const std::string &chainName) :
15  TestingSetup(chainName)
16 {
17  bitdb.MakeMock();
18 
19  bool fFirstRun;
20  std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
21  pwalletMain = new CWallet(std::move(dbw));
22  pwalletMain->LoadWallet(fFirstRun);
23  RegisterValidationInterface(pwalletMain);
24 
26 }
27 
29 {
30  UnregisterValidationInterface(pwalletMain);
31  delete pwalletMain;
32  pwalletMain = nullptr;
33 
34  bitdb.Flush(true);
35  bitdb.Reset();
36 }
CWallet * pwalletMain
void Reset()
Definition: db.cpp:77
void Flush(bool fShutdown)
Definition: db.cpp:598
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
CDBEnv bitdb
Definition: db.cpp:62
void MakeMock()
Definition: db.cpp:149
CRPCTable tableRPC
Definition: server.cpp:567
An instance of this class represents one database.
Definition: db.h:94
DBErrors LoadWallet(bool &fFirstRunRet)
Definition: wallet.cpp:3749
void RegisterWalletRPCCommands(CRPCTable &t)
Definition: rpcwallet.cpp:3398
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:673
WalletTestingSetup(const std::string &chainName=CBaseChainParams::MAIN)