Skip to content

Commit dc2e022

Browse files
committed
[Refactor] fix WalletTestingSetup fixture
1 parent f9d7fe1 commit dc2e022

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed
Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
1-
// Copyright (c) 2016 The Bitcoin Core developers
2-
// Copyright (c) 2020 The PIVX developers
1+
// Copyright (c) 2016-2021 The Bitcoin Core developers
2+
// Copyright (c) 2020-2021 The PIVX developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#include "wallet/test/wallet_test_fixture.h"
77

88
#include "rpc/server.h"
99
#include "wallet/db.h"
10-
#include "wallet/wallet.h"
1110
#include "wallet/rpcwallet.h"
12-
13-
void clean()
14-
{
15-
delete pwalletMain;
16-
pwalletMain = nullptr;
17-
18-
bitdb.Flush(true);
19-
bitdb.Reset();
20-
}
11+
#include "wallet/wallet.h"
2112

2213
WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
2314
SaplingTestingSetup(chainName)
2415
{
25-
clean(); // todo: research why we have an initialized bitdb here.
2616
bitdb.MakeMock();
27-
RegisterWalletRPCCommands(tableRPC);
2817

2918
bool fFirstRun;
3019
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
3120
pwalletMain = new CWallet(std::move(dbw));
3221
pwalletMain->LoadWallet(fFirstRun);
3322
RegisterValidationInterface(pwalletMain);
23+
24+
RegisterWalletRPCCommands(tableRPC);
3425
}
3526

3627
WalletTestingSetup::~WalletTestingSetup()
3728
{
3829
UnregisterValidationInterface(pwalletMain);
39-
clean();
30+
delete pwalletMain;
31+
pwalletMain = nullptr;
32+
33+
bitdb.Flush(true);
34+
bitdb.Reset();
4035
}

src/wallet/test/wallet_test_fixture.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// Copyright (c) 2016 The Bitcoin Core developers
1+
// Copyright (c) 2016-2021 The Bitcoin Core developers
2+
// Copyright (c) 2020-2021 The PIVX developers
23
// Distributed under the MIT software license, see the accompanying
34
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
45

5-
#ifndef BITCOIN_WALLET_TEST_FIXTURE_H
6-
#define BITCOIN_WALLET_TEST_FIXTURE_H
6+
#ifndef PIVX_WALLET_TEST_FIXTURE_H
7+
#define PIVX_WALLET_TEST_FIXTURE_H
78

89
#include "test/librust/sapling_test_fixture.h"
910

11+
1012
/** Testing setup and teardown for wallet.
1113
*/
1214
struct WalletTestingSetup : public SaplingTestingSetup
@@ -20,5 +22,5 @@ struct WalletRegTestingSetup : public WalletTestingSetup
2022
WalletRegTestingSetup() : WalletTestingSetup(CBaseChainParams::REGTEST) {}
2123
};
2224

23-
#endif
25+
#endif // PIVX_WALLET_TEST_FIXTURE_H
2426

0 commit comments

Comments
 (0)