Use TestingSetup to DRY qt rpcnestedtests
This commit is contained in:
parent
7397af9d31
commit
ff6a834fc3
1 changed files with 3 additions and 19 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include "rpc/server.h"
|
#include "rpc/server.h"
|
||||||
#include "rpcconsole.h"
|
#include "rpcconsole.h"
|
||||||
#include "test/testutil.h"
|
#include "test/testutil.h"
|
||||||
|
#include "test/test_bitcoin.h"
|
||||||
#include "univalue.h"
|
#include "univalue.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -35,8 +36,6 @@ void RPCNestedTests::rpcNestedTests()
|
||||||
{
|
{
|
||||||
// do some test setup
|
// do some test setup
|
||||||
// could be moved to a more generic place when we add more tests on QT level
|
// could be moved to a more generic place when we add more tests on QT level
|
||||||
const CChainParams& chainparams = Params();
|
|
||||||
RegisterAllCoreRPCCommands(tableRPC);
|
|
||||||
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
|
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
|
||||||
ClearDatadirCache();
|
ClearDatadirCache();
|
||||||
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
|
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
|
||||||
|
@ -44,15 +43,8 @@ void RPCNestedTests::rpcNestedTests()
|
||||||
dir.mkpath(".");
|
dir.mkpath(".");
|
||||||
ForceSetArg("-datadir", path);
|
ForceSetArg("-datadir", path);
|
||||||
//mempool.setSanityCheck(1.0);
|
//mempool.setSanityCheck(1.0);
|
||||||
pblocktree = new CBlockTreeDB(1 << 20, true);
|
|
||||||
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
|
TestingSetup test;
|
||||||
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
|
|
||||||
InitBlockIndex(chainparams);
|
|
||||||
{
|
|
||||||
CValidationState state;
|
|
||||||
bool ok = ActivateBestChain(state, chainparams);
|
|
||||||
QVERIFY(ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetRPCWarmupFinished();
|
SetRPCWarmupFinished();
|
||||||
|
|
||||||
|
@ -145,13 +137,5 @@ void RPCNestedTests::rpcNestedTests()
|
||||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
|
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UnloadBlockIndex();
|
|
||||||
delete pcoinsTip;
|
|
||||||
pcoinsTip = nullptr;
|
|
||||||
delete pcoinsdbview;
|
|
||||||
pcoinsdbview = nullptr;
|
|
||||||
delete pblocktree;
|
|
||||||
pblocktree = nullptr;
|
|
||||||
|
|
||||||
fs::remove_all(fs::path(path));
|
fs::remove_all(fs::path(path));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue