Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RAW_TEST_FILES = test/data/alertTests.raw
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)

BITCOIN_TEST_SUITE = \
test/test_pivx.h \
test/test_pivx.cpp
# test_pivx binary #
BITCOIN_TESTS =\
Expand Down
23 changes: 22 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5294,10 +5294,31 @@ bool CVerifyDB::VerifyDB(CCoinsView* coinsview, int nCheckLevel, int nCheckDepth

void UnloadBlockIndex()
{
mapBlockIndex.clear();
LOCK(cs_main);
setBlockIndexCandidates.clear();
chainActive.SetTip(NULL);
pindexBestInvalid = NULL;
pindexBestHeader = NULL;
mempool.clear();
mapOrphanTransactions.clear();
mapOrphanTransactionsByPrev.clear();
nSyncStarted = 0;
mapBlocksUnlinked.clear();
vinfoBlockFile.clear();
nLastBlockFile = 0;
nBlockSequenceId = 1;
mapBlockSource.clear();
mapBlocksInFlight.clear();
nQueuedValidatedHeaders = 0;
nPreferredDownload = 0;
setDirtyBlockIndex.clear();
setDirtyFileInfo.clear();
mapNodeState.clear();

for (BlockMap::value_type& entry : mapBlockIndex) {
delete entry.second;
}
mapBlockIndex.clear();
}

bool LoadBlockIndex(string& strError)
Expand Down
3 changes: 2 additions & 1 deletion src/test/Checkpoints_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#include "checkpoints.h"

#include "uint256.h"
#include "test_pivx.h"

#include <boost/test/unit_test.hpp>

using namespace std;

BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(sanity)
{
Expand Down
4 changes: 3 additions & 1 deletion src/test/DoS_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "serialize.h"
#include "util.h"

#include "test/test_pivx.h"

#include <stdint.h>

#include <boost/assign/list_of.hpp> // for 'map_list_of()'
Expand All @@ -40,7 +42,7 @@ CService ip(uint32_t i)
return CService(CNetAddr(s), Params().GetDefaultPort());
}

BOOST_AUTO_TEST_SUITE(DoS_tests)
BOOST_FIXTURE_TEST_SUITE(DoS_tests, TestingSetup)

BOOST_AUTO_TEST_CASE(DoS_banning)
{
Expand Down
4 changes: 3 additions & 1 deletion src/test/accounting_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include "wallet/wallet.h"
#include "wallet/walletdb.h"

#include "test/test_pivx.h"

#include <stdint.h>

#include <boost/test/unit_test.hpp>

extern CWallet* pwalletMain;

BOOST_AUTO_TEST_SUITE(accounting_tests)
BOOST_FIXTURE_TEST_SUITE(accounting_tests, TestingSetup)

static void
GetResults(CWalletDB& walletdb, std::map<CAmount, CAccountingEntry>& results)
Expand Down
4 changes: 3 additions & 1 deletion src/test/alert_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "util.h"
#include "utilstrencodings.h"

#include "test/test_bitcoin.h"

#include <fstream>

#include <boost/filesystem/operations.hpp>
Expand Down Expand Up @@ -77,7 +79,7 @@
}
#endif

struct ReadAlerts
struct ReadAlerts : public TestingSetup
{
ReadAlerts()
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/allocator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
#include "util.h"

#include "allocators.h"
#include "test/test_pivx.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(allocator_tests)
BOOST_FIXTURE_TEST_SUITE(allocator_tests, BasicTestingSetup)

// Dummy memory page locker for platform independent tests
static const void *last_lock_addr, *last_unlock_addr;
Expand Down
4 changes: 2 additions & 2 deletions src/test/arith_uint256_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "arith_uint256.h"
#include <string>
#include "version.h"
#include "test/test_pivx.h"

BOOST_AUTO_TEST_SUITE(arith_uint256_tests)
///BOOST_FIXTURE_TEST_SUITE(arith_uint256_tests, BasicTestingSetup)
BOOST_FIXTURE_TEST_SUITE(arith_uint256_tests, BasicTestingSetup)

/// Convert vector to arith_uint256, via uint256 blob
inline arith_uint256 arith_uint256V(const std::vector<unsigned char>& vch)
Expand Down
3 changes: 2 additions & 1 deletion src/test/base32_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "utilstrencodings.h"
#include "test/test_pivx.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(base32_tests)
BOOST_FIXTURE_TEST_SUITE(base32_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(base32_testvectors)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/base58_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include "test/test_pivx.h"

#include <boost/test/unit_test.hpp>

#include <univalue.h>

extern UniValue read_json(const std::string& jsondata);

BOOST_AUTO_TEST_SUITE(base58_tests)
BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup)

// Goal: test low-level base58 encoding functionality
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
Expand Down
3 changes: 2 additions & 1 deletion src/test/base64_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "utilstrencodings.h"
#include "test/test_pivx.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(base64_tests)
BOOST_FIXTURE_TEST_SUITE(base64_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(base64_testvectors)
{
Expand Down
4 changes: 3 additions & 1 deletion src/test/benchmark_zerocoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "libzerocoin/Coin.h"
#include "libzerocoin/CoinSpend.h"
#include "libzerocoin/Accumulator.h"
#include "test_pivx.h"

using namespace std;
using namespace libzerocoin;
Expand Down Expand Up @@ -402,7 +403,8 @@ Testb_RunAllTests()
cout << ggSuccessfulTests << " out of " << ggNumTests << " tests passed." << endl << endl;
delete gg_Params;
}
BOOST_AUTO_TEST_SUITE(benchmark_zerocoin)

BOOST_FIXTURE_TEST_SUITE(benchmark_zerocoin, TestingSetup)

BOOST_AUTO_TEST_CASE(benchmark_test)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/bip32_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "key.h"
#include "uint256.h"
#include "util.h"
#include "test/test_bitcoin.h"

#include <string>
#include <vector>
Expand Down Expand Up @@ -107,7 +108,7 @@ void RunTest(const TestVector &test) {
}
}

BOOST_AUTO_TEST_SUITE(bip32_tests)
BOOST_FIXTURE_TEST_SUITE(bip32_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(bip32_test1) {
RunTest(test1);
Expand Down
3 changes: 2 additions & 1 deletion src/test/bloom_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include "test/test_pivx.h"

#include <vector>

Expand All @@ -23,7 +24,7 @@
using namespace std;
using namespace boost::tuples;

BOOST_AUTO_TEST_SUITE(bloom_tests)
BOOST_FIXTURE_TEST_SUITE(bloom_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/budget_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
#include "masternode-budget.h"
#include "tinyformat.h"
#include "utilmoneystr.h"
#include "test_pivx.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(budget_tests)
BOOST_FIXTURE_TEST_SUITE(budget_tests, TestingSetup)

void CheckBudgetValue(int nHeight, std::string strNetwork, CAmount nExpectedValue)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/checkblock_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "clientversion.h"
#include "main.h"
#include "utiltime.h"
#include "test/test_pivx.h"

#include <cstdio>

Expand All @@ -19,7 +20,7 @@
#include <boost/test/unit_test.hpp>


BOOST_AUTO_TEST_SUITE(CheckBlock_tests)
BOOST_FIXTURE_TEST_SUITE(CheckBlock_tests, BasicTestingSetup)

bool read_block(const std::string& filename, CBlock& block)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/coins_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "coins.h"
#include "random.h"
#include "uint256.h"
#include "test/test_pivx.h"

#include <vector>
#include <map>
Expand Down Expand Up @@ -60,7 +61,7 @@ class CCoinsViewTest : public CCoinsView
};
}

BOOST_AUTO_TEST_SUITE(coins_tests)
BOOST_FIXTURE_TEST_SUITE(coins_tests, BasicTestingSetup)

static const unsigned int NUM_SIMULATION_ITERATIONS = 40000;

Expand Down
3 changes: 2 additions & 1 deletion src/test/compress_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "compressor.h"
#include "util.h"
#include "test/test_pivx.h"

#include <stdint.h>

Expand All @@ -21,7 +22,7 @@
// amounts 50 .. 21000000
#define NUM_MULTIPLES_50BTC 420000

BOOST_AUTO_TEST_SUITE(compress_tests)
BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup)

bool static TestEncode(uint64_t in) {
return in == CTxOutCompressor::DecompressAmount(CTxOutCompressor::CompressAmount(in));
Expand Down
3 changes: 2 additions & 1 deletion src/test/crypto_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
#include "crypto/hmac_sha512.h"
#include "random.h"
#include "utilstrencodings.h"
#include "test/test_pivx.h"

#include <vector>

#include <boost/assign/list_of.hpp>
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(crypto_tests)
BOOST_FIXTURE_TEST_SUITE(crypto_tests, BasicTestingSetup)

template<typename Hasher, typename In, typename Out>
void TestVector(const Hasher &h, const In &in, const Out &out) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/getarg_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "util.h"
#include "test/test_pivx.h"

#include <string>
#include <vector>

#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(getarg_tests)
BOOST_FIXTURE_TEST_SUITE(getarg_tests, BasicTestingSetup)

static void ResetArgs(const std::string& strArg)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/hash_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

#include "hash.h"
#include "utilstrencodings.h"
#include "test/test_pivx.h"

#include <vector>

#include <boost/test/unit_test.hpp>

using namespace std;

BOOST_AUTO_TEST_SUITE(hash_tests)
BOOST_FIXTURE_TEST_SUITE(hash_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(murmurhash3)
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/key_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include "test_pivx.h"

#include <string>
#include <vector>
Expand Down Expand Up @@ -58,8 +59,7 @@ void dumpKeyInfo(uint256 privkey)
}
#endif


BOOST_AUTO_TEST_SUITE(key_tests)
BOOST_FIXTURE_TEST_SUITE(key_tests, TestingSetup)

BOOST_AUTO_TEST_CASE(key_test1)
{
Expand Down
Loading