Fix parameter naming inconsistencies between .h and .cpp files
[bitcoinplatinum.git] / src / test / test_bitcoin.h
bloba593f136eb68c97a89cbbcbeda1b28f43936aeae
1 // Copyright (c) 2015-2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_TEST_TEST_BITCOIN_H
6 #define BITCOIN_TEST_TEST_BITCOIN_H
8 #include "chainparamsbase.h"
9 #include "key.h"
10 #include "pubkey.h"
11 #include "txdb.h"
12 #include "txmempool.h"
14 #include <boost/filesystem.hpp>
15 #include <boost/thread.hpp>
17 /** Basic testing setup.
18 * This just configures logging and chain parameters.
20 struct BasicTestingSetup {
21 ECCVerifyHandle globalVerifyHandle;
23 BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
24 ~BasicTestingSetup();
27 /** Testing setup that configures a complete environment.
28 * Included are data directory, coins database, script check threads setup.
30 class CConnman;
31 struct TestingSetup: public BasicTestingSetup {
32 CCoinsViewDB *pcoinsdbview;
33 boost::filesystem::path pathTemp;
34 boost::thread_group threadGroup;
35 CConnman* connman;
37 TestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
38 ~TestingSetup();
41 class CBlock;
42 struct CMutableTransaction;
43 class CScript;
46 // Testing fixture that pre-creates a
47 // 100-block REGTEST-mode block chain
49 struct TestChain100Setup : public TestingSetup {
50 TestChain100Setup();
52 // Create a new block with just given transactions, coinbase paying to
53 // scriptPubKey, and try to add it to the current chain.
54 CBlock CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns,
55 const CScript& scriptPubKey);
57 ~TestChain100Setup();
59 std::vector<CTransaction> coinbaseTxns; // For convenience, coinbase transactions
60 CKey coinbaseKey; // private/public key needed to spend coinbase transactions
63 class CTxMemPoolEntry;
65 struct TestMemPoolEntryHelper
67 // Default values
68 CAmount nFee;
69 int64_t nTime;
70 unsigned int nHeight;
71 bool spendsCoinbase;
72 unsigned int sigOpCost;
73 LockPoints lp;
75 TestMemPoolEntryHelper() :
76 nFee(0), nTime(0), nHeight(1),
77 spendsCoinbase(false), sigOpCost(4) { }
79 CTxMemPoolEntry FromTx(const CMutableTransaction &tx);
80 CTxMemPoolEntry FromTx(const CTransaction &tx);
82 // Change the default value
83 TestMemPoolEntryHelper &Fee(CAmount _fee) { nFee = _fee; return *this; }
84 TestMemPoolEntryHelper &Time(int64_t _time) { nTime = _time; return *this; }
85 TestMemPoolEntryHelper &Height(unsigned int _height) { nHeight = _height; return *this; }
86 TestMemPoolEntryHelper &SpendsCoinbase(bool _flag) { spendsCoinbase = _flag; return *this; }
87 TestMemPoolEntryHelper &SigOpsCost(unsigned int _sigopsCost) { sigOpCost = _sigopsCost; return *this; }
89 #endif