Browse Source

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.
0.15
Russell Yanofsky 7 years ago
parent
commit
91e303595b
  1. 1
      src/Makefile.test.include
  2. 28
      src/test/test_bitcoin.cpp
  3. 26
      src/test/test_bitcoin_main.cpp

1
src/Makefile.test.include

@ -126,6 +126,7 @@ BITCOIN_TESTS =\ @@ -126,6 +126,7 @@ BITCOIN_TESTS =\
test/streams_tests.cpp \
test/test_bitcoin.cpp \
test/test_bitcoin.h \
test/test_bitcoin_main.cpp \
test/test_random.h \
test/testutil.cpp \
test/testutil.h \

28
src/test/test_bitcoin.cpp

@ -2,8 +2,6 @@ @@ -2,8 +2,6 @@
// 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 "test_bitcoin.h"
#include "chainparams.h"
@ -27,10 +25,8 @@ @@ -27,10 +25,8 @@
#include <memory>
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
std::unique_ptr<CConnman> g_connman;
FastRandomContext insecure_rand_ctx(true);
extern bool fPrintToConsole;
@ -69,11 +65,14 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha @@ -69,11 +65,14 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
BOOST_REQUIRE(InitBlockIndex(chainparams));
if (!InitBlockIndex(chainparams)) {
throw std::runtime_error("InitBlockIndex failed.");
}
{
CValidationState state;
bool ok = ActivateBestChain(state, chainparams);
BOOST_REQUIRE(ok);
if (!ActivateBestChain(state, chainparams)) {
throw std::runtime_error("ActivateBestChain failed.");
}
}
nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++)
@ -150,18 +149,3 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransaction &txn) { @@ -150,18 +149,3 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransaction &txn) {
return CTxMemPoolEntry(MakeTransactionRef(txn), nFee, nTime, nHeight,
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

@ -0,0 +1,26 @@ @@ -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…
Cancel
Save