Make test_bitcoin.cpp compatible with Qt Test framework
Move Boost.Test main function and global overrides to a new test_bitcoin_main.cpp file.
This commit is contained in:
parent
8910b4717e
commit
91e303595b
3 changed files with 33 additions and 22 deletions
|
@ -126,6 +126,7 @@ BITCOIN_TESTS =\
|
||||||
test/streams_tests.cpp \
|
test/streams_tests.cpp \
|
||||||
test/test_bitcoin.cpp \
|
test/test_bitcoin.cpp \
|
||||||
test/test_bitcoin.h \
|
test/test_bitcoin.h \
|
||||||
|
test/test_bitcoin_main.cpp \
|
||||||
test/test_random.h \
|
test/test_random.h \
|
||||||
test/testutil.cpp \
|
test/testutil.cpp \
|
||||||
test/testutil.h \
|
test/testutil.h \
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE Bitcoin Test Suite
|
|
||||||
|
|
||||||
#include "test_bitcoin.h"
|
#include "test_bitcoin.h"
|
||||||
|
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
|
@ -27,10 +25,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/test/unit_test.hpp>
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
std::unique_ptr<CConnman> g_connman;
|
|
||||||
FastRandomContext insecure_rand_ctx(true);
|
FastRandomContext insecure_rand_ctx(true);
|
||||||
|
|
||||||
extern bool fPrintToConsole;
|
extern bool fPrintToConsole;
|
||||||
|
@ -69,11 +65,14 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
||||||
pblocktree = new CBlockTreeDB(1 << 20, true);
|
pblocktree = new CBlockTreeDB(1 << 20, true);
|
||||||
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
|
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
|
||||||
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
|
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
|
||||||
BOOST_REQUIRE(InitBlockIndex(chainparams));
|
if (!InitBlockIndex(chainparams)) {
|
||||||
|
throw std::runtime_error("InitBlockIndex failed.");
|
||||||
|
}
|
||||||
{
|
{
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
bool ok = ActivateBestChain(state, chainparams);
|
if (!ActivateBestChain(state, chainparams)) {
|
||||||
BOOST_REQUIRE(ok);
|
throw std::runtime_error("ActivateBestChain failed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nScriptCheckThreads = 3;
|
nScriptCheckThreads = 3;
|
||||||
for (int i=0; i < nScriptCheckThreads-1; i++)
|
for (int i=0; i < nScriptCheckThreads-1; i++)
|
||||||
|
@ -150,18 +149,3 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransaction &txn) {
|
||||||
return CTxMemPoolEntry(MakeTransactionRef(txn), nFee, nTime, nHeight,
|
return CTxMemPoolEntry(MakeTransactionRef(txn), nFee, nTime, nHeight,
|
||||||
spendsCoinbase, sigOpCost, lp);
|
spendsCoinbase, sigOpCost, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown(void* parg)
|
|
||||||
{
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartShutdown()
|
|
||||||
{
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShutdownRequested()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
26
src/test/test_bitcoin_main.cpp
Normal file
26
src/test/test_bitcoin_main.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (c) 2011-2016 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#define BOOST_TEST_MODULE Bitcoin Test Suite
|
||||||
|
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
std::unique_ptr<CConnman> g_connman;
|
||||||
|
|
||||||
|
void Shutdown(void* parg)
|
||||||
|
{
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartShutdown()
|
||||||
|
{
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShutdownRequested()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
Loading…
Reference in a new issue