Skip to content

Commit ff6a834

Browse files
committed
Use TestingSetup to DRY qt rpcnestedtests
1 parent 7397af9 commit ff6a834

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

src/qt/test/rpcnestedtests.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "rpc/server.h"
1313
#include "rpcconsole.h"
1414
#include "test/testutil.h"
15+
#include "test/test_bitcoin.h"
1516
#include "univalue.h"
1617
#include "util.h"
1718

@@ -35,24 +36,15 @@ void RPCNestedTests::rpcNestedTests()
3536
{
3637
// do some test setup
3738
// could be moved to a more generic place when we add more tests on QT level
38-
const CChainParams& chainparams = Params();
39-
RegisterAllCoreRPCCommands(tableRPC);
4039
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
4140
ClearDatadirCache();
4241
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
4342
QDir dir(QString::fromStdString(path));
4443
dir.mkpath(".");
4544
ForceSetArg("-datadir", path);
4645
//mempool.setSanityCheck(1.0);
47-
pblocktree = new CBlockTreeDB(1 << 20, true);
48-
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
49-
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
50-
InitBlockIndex(chainparams);
51-
{
52-
CValidationState state;
53-
bool ok = ActivateBestChain(state, chainparams);
54-
QVERIFY(ok);
55-
}
46+
47+
TestingSetup test;
5648

5749
SetRPCWarmupFinished();
5850

@@ -145,13 +137,5 @@ void RPCNestedTests::rpcNestedTests()
145137
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
146138
#endif
147139

148-
UnloadBlockIndex();
149-
delete pcoinsTip;
150-
pcoinsTip = nullptr;
151-
delete pcoinsdbview;
152-
pcoinsdbview = nullptr;
153-
delete pblocktree;
154-
pblocktree = nullptr;
155-
156140
fs::remove_all(fs::path(path));
157141
}

0 commit comments

Comments
 (0)