Skip to content

Commit

Permalink
tests: add a BasicTestingSetup and apply to all tests
Browse files Browse the repository at this point in the history
Make sure that chainparams and logging is properly initialized. Doing
this for every test may be overkill, but this initialization is so
simple that that does not matter.

This should fix the travis issues.
  • Loading branch information
laanwj committed Mar 12, 2015
1 parent e564e63 commit 92fd887
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 36 deletions.
3 changes: 2 additions & 1 deletion src/test/Checkpoints_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
#include "checkpoints.h"

#include "uint256.h"
#include "test/test_bitcoin.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
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_bitcoin.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
3 changes: 2 additions & 1 deletion src/test/arith_uint256_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#include "arith_uint256.h"
#include <string>
#include "version.h"
#include "test/test_bitcoin.h"

BOOST_AUTO_TEST_SUITE(arith_uint256_tests)
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_bitcoin.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 @@ -13,6 +13,7 @@
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include "test/test_bitcoin.h"

#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
Expand All @@ -23,7 +24,7 @@
using namespace json_spirit;
extern Array 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_bitcoin.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
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 @@ -13,6 +13,7 @@
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include "test/test_bitcoin.h"

#include <vector>

Expand All @@ -21,7 +22,7 @@

using namespace std;

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/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_bitcoin.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_bitcoin.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_bitcoin.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 @@ -10,13 +10,14 @@
#include "crypto/hmac_sha512.h"
#include "random.h"
#include "utilstrencodings.h"
#include "test/test_bitcoin.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 @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

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

#include <string>
#include <vector>
Expand All @@ -11,7 +12,7 @@
#include <boost/foreach.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_bitcoin.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
3 changes: 2 additions & 1 deletion src/test/key_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "uint256.h"
#include "util.h"
#include "utilstrencodings.h"
#include "test/test_bitcoin.h"

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


BOOST_AUTO_TEST_SUITE(key_tests)
BOOST_FIXTURE_TEST_SUITE(key_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(key_test1)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/mruset_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "random.h"
#include "util.h"
#include "test/test_bitcoin.h"

#include <set>

Expand Down Expand Up @@ -34,7 +35,7 @@ class mrutester
}
};

BOOST_AUTO_TEST_SUITE(mruset_tests)
BOOST_FIXTURE_TEST_SUITE(mruset_tests, BasicTestingSetup)

// Test that an mruset behaves like a set, as long as no more than MAX_SIZE elements are in it
BOOST_AUTO_TEST_CASE(mruset_like_set)
Expand Down
3 changes: 2 additions & 1 deletion src/test/multisig_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "script/interpreter.h"
#include "script/sign.h"
#include "uint256.h"
#include "test/test_bitcoin.h"

#ifdef ENABLE_WALLET
#include "wallet_ismine.h"
Expand All @@ -22,7 +23,7 @@ using namespace std;

typedef vector<unsigned char> valtype;

BOOST_AUTO_TEST_SUITE(multisig_tests)
BOOST_FIXTURE_TEST_SUITE(multisig_tests, BasicTestingSetup)

CScript
sign_multisig(CScript scriptPubKey, vector<CKey> keys, CTransaction transaction, int whichIn)
Expand Down
3 changes: 2 additions & 1 deletion src/test/netbase_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "netbase.h"
#include "test/test_bitcoin.h"

#include <string>

#include <boost/test/unit_test.hpp>

using namespace std;

BOOST_AUTO_TEST_SUITE(netbase_tests)
BOOST_FIXTURE_TEST_SUITE(netbase_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(netbase_networks)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/pmt_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "arith_uint256.h"
#include "version.h"
#include "random.h"
#include "test/test_bitcoin.h"

#include <vector>

Expand All @@ -28,7 +29,7 @@ class CPartialMerkleTreeTester : public CPartialMerkleTree
}
};

BOOST_AUTO_TEST_SUITE(pmt_tests)
BOOST_FIXTURE_TEST_SUITE(pmt_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(pmt_test1)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/pow_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
#include "main.h"
#include "pow.h"
#include "util.h"
#include "test/test_bitcoin.h"

#include <boost/test/unit_test.hpp>

using namespace std;

BOOST_AUTO_TEST_SUITE(pow_tests)
BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)

/* Test calculation of next difficulty target with no constraints applying */
BOOST_AUTO_TEST_CASE(get_next_work)
Expand Down
4 changes: 3 additions & 1 deletion src/test/sanity_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#include "compat/sanity.h"
#include "key.h"
#include "test/test_bitcoin.h"

#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(sanity_tests)

BOOST_FIXTURE_TEST_SUITE(sanity_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(basic_sanity)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/script_P2SH_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "script/script.h"
#include "script/script_error.h"
#include "script/sign.h"
#include "test/test_bitcoin.h"

#ifdef ENABLE_WALLET
#include "wallet_ismine.h"
Expand Down Expand Up @@ -47,7 +48,7 @@ Verify(const CScript& scriptSig, const CScript& scriptPubKey, bool fStrict, Scri
}


BOOST_AUTO_TEST_SUITE(script_P2SH_tests)
BOOST_FIXTURE_TEST_SUITE(script_P2SH_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(sign)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "script/script_error.h"
#include "script/sign.h"
#include "util.h"
#include "test/test_bitcoin.h"

#if defined(HAVE_CONSENSUS_LIB)
#include "script/bitcoinconsensus.h"
Expand Down Expand Up @@ -53,7 +54,7 @@ read_json(const std::string& jsondata)
return v.get_array();
}

BOOST_AUTO_TEST_SUITE(script_tests)
BOOST_FIXTURE_TEST_SUITE(script_tests, BasicTestingSetup)

CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey)
{
Expand Down
5 changes: 4 additions & 1 deletion src/test/scriptnum_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

#include "bignum.h"
#include "script/script.h"
#include "test/test_bitcoin.h"

#include <boost/test/unit_test.hpp>
#include <limits.h>
#include <stdint.h>
BOOST_AUTO_TEST_SUITE(scriptnum_tests)

BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup)

static const int64_t values[] = \
{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, UINT_MAX, LONG_MIN, LONG_MAX };
Expand Down
3 changes: 2 additions & 1 deletion src/test/serialize_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
#include "serialize.h"
#include "streams.h"
#include "hash.h"
#include "test/test_bitcoin.h"

#include <stdint.h>

#include <boost/test/unit_test.hpp>

using namespace std;

BOOST_AUTO_TEST_SUITE(serialize_tests)
BOOST_FIXTURE_TEST_SUITE(serialize_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(sizes)
{
Expand Down
Loading

0 comments on commit 92fd887

Please sign in to comment.