mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-29 18:05:58 +02:00
Merge #15504: fuzz: Link BasicTestingSetup (shared with unit tests)
faa9b88199fuzz: Link BasicTestingSetup (shared with unit tests) (MarcoFalke)fa85468cd2test: Move main_tests to validation_tests (MarcoFalke)fa02b22245test: Remove useless test_bitcoin_main.cpp (MarcoFalke)fab2daa026test: Add missing LIBBITCOIN_ZMQ to test_test_bitcoin_LDADD (MarcoFalke) Pull request description: Link against BasicTestingSetup in the fuzz tests, so we can fuzz against validation. Also include a commit to remove test_bitcoin_main.cpp. That file may or may not overwrite globals in the link stage depending on the link order. This is confusing and useless anyway: The unit tests should never `std::exit` in the middle of the run (especially with success as exit code), since it will skip all test modules afterward. Also include a commit to remove some unused forward declarations and move the main_tests to validation_tests, since main was long ago split into net_processing and validation. Tree-SHA512: bdd34c87505450ec106d632f6664aadcbdac7c198172a77da55fab75b274f869ae1a8d06573ba2aff4cb186be9c7a34b7697894ab6f9c82b392f769c9135f36c
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
#include <vector>
|
||||
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
||||
void test_one_input(std::vector<uint8_t> buffer);
|
||||
|
||||
#endif // BITCOIN_TEST_FUZZ_FUZZ_H
|
||||
|
||||
7
src/test/main.cpp
Normal file
7
src/test/main.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2011-2019 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 Core Test Suite
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@@ -66,36 +66,36 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
||||
{
|
||||
SetDataDir("tempdir");
|
||||
const CChainParams& chainparams = Params();
|
||||
// Ideally we'd move all the RPC tests to the functional testing framework
|
||||
// instead of unit tests, but for now we need these here.
|
||||
// Ideally we'd move all the RPC tests to the functional testing framework
|
||||
// instead of unit tests, but for now we need these here.
|
||||
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
ClearDatadirCache();
|
||||
RegisterAllCoreRPCCommands(tableRPC);
|
||||
ClearDatadirCache();
|
||||
|
||||
// We have to run a scheduler thread to prevent ActivateBestChain
|
||||
// from blocking due to queue overrun.
|
||||
threadGroup.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
||||
// We have to run a scheduler thread to prevent ActivateBestChain
|
||||
// from blocking due to queue overrun.
|
||||
threadGroup.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
||||
|
||||
mempool.setSanityCheck(1.0);
|
||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
||||
pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
|
||||
pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
|
||||
if (!LoadGenesisBlock(chainparams)) {
|
||||
throw std::runtime_error("LoadGenesisBlock failed.");
|
||||
}
|
||||
{
|
||||
CValidationState state;
|
||||
if (!ActivateBestChain(state, chainparams)) {
|
||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", FormatStateMessage(state)));
|
||||
}
|
||||
}
|
||||
nScriptCheckThreads = 3;
|
||||
for (int i=0; i < nScriptCheckThreads-1; i++)
|
||||
threadGroup.create_thread(&ThreadScriptCheck);
|
||||
mempool.setSanityCheck(1.0);
|
||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
||||
pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
|
||||
pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
|
||||
if (!LoadGenesisBlock(chainparams)) {
|
||||
throw std::runtime_error("LoadGenesisBlock failed.");
|
||||
}
|
||||
|
||||
g_banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
g_connman = MakeUnique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests.
|
||||
CValidationState state;
|
||||
if (!ActivateBestChain(state, chainparams)) {
|
||||
throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", FormatStateMessage(state)));
|
||||
}
|
||||
|
||||
nScriptCheckThreads = 3;
|
||||
for (int i = 0; i < nScriptCheckThreads - 1; i++)
|
||||
threadGroup.create_thread(&ThreadScriptCheck);
|
||||
|
||||
g_banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
g_connman = MakeUnique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests.
|
||||
}
|
||||
|
||||
TestingSetup::~TestingSetup()
|
||||
|
||||
@@ -71,10 +71,6 @@ private:
|
||||
/** Testing setup that configures a complete environment.
|
||||
* Included are data directory, coins database, script check threads setup.
|
||||
*/
|
||||
class CConnman;
|
||||
class CNode;
|
||||
|
||||
class PeerLogicValidation;
|
||||
struct TestingSetup : public BasicTestingSetup {
|
||||
boost::thread_group threadGroup;
|
||||
CScheduler scheduler;
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright (c) 2011-2018 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 <banman.h>
|
||||
#include <net.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
std::unique_ptr<CConnman> g_connman;
|
||||
std::unique_ptr<BanMan> g_banman;
|
||||
|
||||
[[noreturn]] void Shutdown(void* parg)
|
||||
{
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
[[noreturn]] void StartShutdown()
|
||||
{
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
bool ShutdownRequested()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
// Copyright (c) 2014-2018 The Bitcoin Core developers
|
||||
// Copyright (c) 2014-2019 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <validation.h>
|
||||
#include <net.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <test/test_bitcoin.h>
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(main_tests, TestingSetup)
|
||||
BOOST_FIXTURE_TEST_SUITE(validation_tests, TestingSetup)
|
||||
|
||||
static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams)
|
||||
{
|
||||
Reference in New Issue
Block a user