1 // Copyright (c) 2011-2019 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.
4
5 #include <chainparams.h>
6 #include <coins.h>
7 #include <consensus/consensus.h>
8 #include <consensus/merkle.h>
9 #include <consensus/tx_verify.h>
10 #include <miner.h>
11 #include <policy/policy.h>
12 #include <script/standard.h>
13 #include <txmempool.h>
14 #include <uint256.h>
15 #include <util/strencodings.h>
16 #include <util/system.h>
17 #include <util/time.h>
18 #include <validation.h>
19
20 #include <test/util/setup_common.h>
21
22 #include <memory>
23
24 #include <boost/test/unit_test.hpp>
25
26 namespace miner_tests {
27 struct MinerTestingSetup : public TestingSetup {
28 void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_node.mempool->cs);
TestSequenceLocksminer_tests::MinerTestingSetup29 bool TestSequenceLocks(const CTransaction& tx, int flags) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_node.mempool->cs)
30 {
31 return CheckSequenceLocks(*m_node.mempool, tx, flags);
32 }
33 BlockAssembler AssemblerForTest(const CChainParams& params);
34 };
35 } // namespace miner_tests
36
37 BOOST_FIXTURE_TEST_SUITE(miner_tests, MinerTestingSetup)
38
39 // BOOST_CHECK_EXCEPTION predicates to check the specific validation error
40 class HasReason {
41 public:
HasReason(const std::string & reason)42 explicit HasReason(const std::string& reason) : m_reason(reason) {}
operator ()(const std::runtime_error & e) const43 bool operator() (const std::runtime_error& e) const {
44 return std::string(e.what()).find(m_reason) != std::string::npos;
45 };
46 private:
47 const std::string m_reason;
48 };
49
50 static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
51
AssemblerForTest(const CChainParams & params)52 BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params)
53 {
54 BlockAssembler::Options options;
55
56 options.nBlockMaxWeight = dgpMaxBlockWeight;
57 options.blockMinFeeRate = blockMinFeeRate;
58 return BlockAssembler(*m_node.mempool, params, options);
59 }
60
61 constexpr static struct {
62 unsigned char extranonce;
63 unsigned int nonce;
64 } blockinfo[] = {
65 {4, 0x000135b5}, {2, 0x0001535a}, {1, 0x00029f51}, {1, 0x000447a7},
66 {2, 0x00046a5d}, {2, 0x000452af}, {1, 0x000463ec}, {2, 0x00062f5e},
67 {2, 0x00079e2c}, {1, 0x0008a304}, {1, 0x000ae9a9}, {2, 0x000a6c15},
68 {2, 0x000b38f8}, {1, 0x000c58a1}, {2, 0x000ba426}, {2, 0x000dfb38},
69 {1, 0x000eb164}, {2, 0x000e46d9}, {1, 0x000e38c7}, {1, 0x000e4ff9},
70 {3, 0x00102efa}, {2, 0x0011c056}, {2, 0x001158b9}, {1, 0x00144969},
71 {2, 0x00146f39}, {1, 0x0014d8e8}, {2, 0x001601bc}, {2, 0x0016551d},
72 {2, 0x00177b22}, {2, 0x0018e947}, {2, 0x0019bb2d}, {2, 0x001bdc48},
73 {1, 0x0019fac5}, {2, 0x001b724d}, {2, 0x001b3967}, {1, 0x001dddb0},
74 {2, 0x001fb782}, {1, 0x001fb80f}, {2, 0x00220adb}, {1, 0x0023a504},
75 {1, 0x0024a22d}, {3, 0x00250dd7}, {2, 0x0025ee99}, {5, 0x0027b428},
76 {1, 0x002b2a28}, {5, 0x00299ac8}, {1, 0x0028a6cb}, {1, 0x002adf44},
77 {1, 0x002a8060}, {2, 0x002b99be}, {1, 0x002e9f05}, {1, 0x00306140},
78 {1, 0x002fa812}, {1, 0x0031ba13}, {5, 0x0033d7c8}, {5, 0x0032f635},
79 {1, 0x00361303}, {1, 0x0035ec1e}, {6, 0x003ac161}, {2, 0x003b8c90},
80 {2, 0x003a8544}, {1, 0x003befbf}, {1, 0x003c4593}, {1, 0x003dc673},
81 {2, 0x003c86fe}, {2, 0x003d6942}, {1, 0x003ffb6e}, {1, 0x0040b722},
82 {1, 0x004395ba}, {5, 0x004aa396}, {5, 0x004c338c}, {1, 0x004cb1cb},
83 {1, 0x004f17fd}, {2, 0x004e5b2a}, {2, 0x004f5944}, {1, 0x00503c96},
84 {2, 0x004f265c}, {1, 0x004f4d4d}, {2, 0x005058c9}, {2, 0x0052148c},
85 {1, 0x005489f8}, {1, 0x0054dd61}, {1, 0x005686fb}, {5, 0x00598f70},
86 {1, 0x0059064b}, {1, 0x005b574c}, {1, 0x005bc594}, {1, 0x005e65fe},
87 {1, 0x005e9c05}, {1, 0x0060c7a3}, {1, 0x005ef50f}, {2, 0x00607240},
88 {0, 0x0060f60f}, {1, 0x00626677}, {2, 0x0061feb9}, {2, 0x00644c94},
89 {2, 0x00655ec3}, {1, 0x006632cd}, {1, 0x006a4091}, {1, 0x006a5d59},
90 {1, 0x006b4be0}, {1, 0x006bd08f}, {1, 0x006dd899}, {5, 0x0075b7ce},
91 {2, 0x006dd957}, {1, 0x006ddd91}, {1, 0x00700ff2}, {1, 0x007177dd},
92 {2, 0x0070ef64}, {2, 0x0072fdfe}, {4, 0x0076ecfb}, {2, 0x0076bfe7},
93 {1, 0x0078a1c1}, {1, 0x00795659}, {2, 0x007989e8}, {2, 0x007d378e},
94 {1, 0x007ac186}, {2, 0x007afd06}, {2, 0x007b3640}, {1, 0x007bcbd8},
95 {1, 0x007bebf5}, {2, 0x00811938}, {2, 0x007f1a60}, {1, 0x007f59b6},
96 {2, 0x008020b2}, {2, 0x0082919a}, {1, 0x0082d03d}, {2, 0x008372ff},
97 {1, 0x0083d1bc}, {1, 0x0083a951}, {3, 0x008456c3}, {2, 0x008983bf},
98 {2, 0x0089d194}, {1, 0x008c74a1}, {2, 0x008b9d71}, {1, 0x008daf24},
99 {2, 0x008d97b1}, {2, 0x008e3f8c}, {2, 0x008e18ea}, {2, 0x0091d324},
100 {2, 0x00940a83}, {2, 0x009446ed}, {1, 0x00958602}, {2, 0x00957089},
101 {2, 0x00955338}, {1, 0x009721cc}, {2, 0x0096284d}, {1, 0x0095e5b9},
102 {2, 0x009772cb}, {1, 0x0099d53b}, {1, 0x0099860c}, {3, 0x009a3b3b},
103 {2, 0x009e6597}, {5, 0x009b44be}, {1, 0x009ae757}, {5, 0x009c89bf},
104 {1, 0x009cd503}, {1, 0x009d9a08}, {1, 0x009dbc32}, {2, 0x009fae8a},
105 {1, 0x009fa89d}, {1, 0x00a0f881}, {1, 0x00a08f52}, {1, 0x00a0cfb2},
106 {5, 0x00a0b3d9}, {5, 0x00a189d6}, {1, 0x00a3f1e4}, {1, 0x00a34149},
107 {6, 0x00a54ae6}, {2, 0x00a76413}, {2, 0x00a731ac}, {1, 0x00aa1e61},
108 {1, 0x00aae545}, {1, 0x00ae616e}, {2, 0x00af8b04}, {2, 0x00b15897},
109 {1, 0x00b1d797}, {1, 0x00b2514a}, {1, 0x00b6da2c}, {5, 0x00b5d69d},
110 {5, 0x00b60f8b}, {1, 0x00b7ddf4}, {1, 0x00b7f2d6}, {2, 0x00b9f1b8},
111 {2, 0x00bb1328}, {1, 0x00c3b765}, {2, 0x00c3c4c1}, {1, 0x00c35e83},
112 {2, 0x00c3299f}, {2, 0x00c6d7ca}, {1, 0x00c8cf93}, {1, 0x00c80b8c},
113 {1, 0x00c72875}, {5, 0x00c7a637}, {1, 0x00c8e4b7}, {1, 0x00ca7818},
114 {1, 0x00cbf135}, {1, 0x00cc76e1}, {1, 0x00cda36a}, {1, 0x00cc8307},
115 {1, 0x00ce5bac}, {2, 0x00cf4fd3}, {0, 0x00cf91a4}, {1, 0x00d03423},
116 {2, 0x00d06969}, {2, 0x00d07d66}, {2, 0x00d0302f}, {1, 0x00d13474},
117 {1, 0x00d3155e}, {1, 0x00d1b9bc}, {1, 0x00d25df2}, {1, 0x00d1f159},
118 {1, 0x00d3007c}, {5, 0x00d3bf36}, {2, 0x00d70c84}, {1, 0x00d5e3d4},
119 {1, 0x00db4fbc}, {1, 0x00d9267f}, {2, 0x00d8ac8a}, {2, 0x00d9a8b9},
120 {4, 0x00d94ff2}, {2, 0x00d94334}, {1, 0x00dab723}, {1, 0x00e09787},
121 {2, 0x00dfec52}, {2, 0x00e0a697}, {1, 0x00e0527b}, {2, 0x00e13147},
122 {2, 0x00e3fcbd}, {1, 0x00e457fd}, {1, 0x00e52160}, {2, 0x00e5ee55},
123 {2, 0x00e63f4f}, {1, 0x00e6c82f}, {2, 0x00e85025}, {2, 0x00ed6541},
124 {1, 0x00edb959}, {2, 0x00ef2b7f}, {1, 0x00f3949a}, {1, 0x00f440bf},
125 {3, 0x00f745dc}, {2, 0x00f6fe41}, {2, 0x00fa4ae2}, {1, 0x00faa6a6},
126 {2, 0x00fd1c9a}, {1, 0x00fbe743}, {2, 0x00fcf092}, {2, 0x00fe2a3e},
127 {2, 0x00fd7cc5}, {2, 0x00ff701e}, {2, 0x0100e795}, {2, 0x0100942d},
128 {1, 0x01021e8c}, {2, 0x01037e9a}, {2, 0x0104892d}, {1, 0x0108794c},
129 {2, 0x01096d59}, {1, 0x0109f51d}, {2, 0x010b3152}, {1, 0x010d491b},
130 {1, 0x010eda18}, {3, 0x010eae14}, {2, 0x01124e31}, {5, 0x01104819},
131 {1, 0x0112cbc8}, {5, 0x01123ea2}, {1, 0x0112e2ce}, {1, 0x01129f34},
132 {1, 0x0114ff67}, {2, 0x0116ec09}, {1, 0x011664b4}, {1, 0x011984af},
133 {1, 0x011b8afc}, {1, 0x011cbfc9}, {5, 0x011f52cf}, {5, 0x011d569a},
134 {1, 0x011da9ed}, {1, 0x0121dd81}, {6, 0x01201296}, {2, 0x01207bd7},
135 {2, 0x0124163c}, {1, 0x01275484}, {1, 0x0124e21a}, {1, 0x0125f068},
136 {2, 0x0126614a}, {2, 0x0127a6fe}, {1, 0x012865fb}, {1, 0x012a4f19},
137 {1, 0x012b3841}, {5, 0x012c7c35}, {5, 0x012fbe45}, {1, 0x01306e93},
138 {1, 0x0131cbc4}, {2, 0x01323e3d}, {2, 0x013698a4}, {1, 0x01349f3c},
139 {2, 0x01360791}, {1, 0x01372a89}, {2, 0x01374e37}, {2, 0x0138ce82},
140 {1, 0x01381729}, {1, 0x013a4922}, {1, 0x013b21ea}, {5, 0x013c035d},
141 {1, 0x013c2648}, {1, 0x013cea75}, {1, 0x013f953a}, {1, 0x013d409a},
142 {1, 0x013e2eba}, {1, 0x01406e6d}, {1, 0x013e9b18}, {2, 0x013ea1e7},
143 {0, 0x0146472a}, {1, 0x01453129}, {2, 0x01444e90}, {2, 0x014558c3},
144 {2, 0x0145c66a}, {1, 0x0146a5c5}, {1, 0x01499c5c}, {1, 0x014b3719},
145 {1, 0x014c82d6}, {1, 0x014c61fe}, {1, 0x014d7d29}, {5, 0x014f6021},
146 {2, 0x014f8391}, {1, 0x014faa01}, {1, 0x0150f07f}, {1, 0x01508eec},
147 {2, 0x015339f7}, {2, 0x01522946}, {4, 0x0153d413}, {2, 0x01531132},
148 {1, 0x01539c10}, {1, 0x01538fa3}, {2, 0x01568d50}, {2, 0x01570520},
149 {1, 0x01598663}, {2, 0x0158f956}, {2, 0x0159de4c}, {1, 0x015e2e2a},
150 {1, 0x015e0f39}, {2, 0x015dc1aa}, {2, 0x015e7ef0}, {1, 0x015dd8e4},
151 {2, 0x0160427f}, {2, 0x015fd33e}, {1, 0x015fcd11}, {2, 0x016129e2},
152 {1, 0x01608d9f}, {1, 0x01618bb9}, {3, 0x0161c62c}, {2, 0x0162cb31},
153 {2, 0x0165398b}, {1, 0x0166ad09}, {2, 0x0167610e}, {1, 0x016727cb},
154 {2, 0x01675f3d}, {2, 0x016b1e1b}, {2, 0x016afabc}, {2, 0x016ad30c},
155 {2, 0x016c733b}, {2, 0x016e02ae}, {1, 0x016ccb3b}, {2, 0x016e68ac},
156 {2, 0x016eb853}, {1, 0x016fd28c}, {2, 0x017208c1}, {1, 0x017129d5},
157 {2, 0x0173c8a5}, {1, 0x01742270}, {1, 0x017409d7}, {3, 0x01744606},
158 {2, 0x0178d4de}, {5, 0x017755fd}, {1, 0x0177bae9}, {5, 0x017a98f4},
159 {1, 0x017abf35}, {1, 0x017a273e}, {1, 0x0179dab0}, {2, 0x017c1698},
160 {1, 0x017b6e4c}, {1, 0x017aa311}, {1, 0x017dc7a0}, {1, 0x017e5421},
161 {5, 0x017fc31a}, {5, 0x01814d53}, {1, 0x017eafba}, {1, 0x017f20cc},
162 {6, 0x017fa19c}, {2, 0x0180a3b1}, {2, 0x0180ba39}, {1, 0x0180cbaa},
163 {1, 0x01815cfb}, {1, 0x0185280d}, {2, 0x018583ff}, {2, 0x0184e4fc},
164 {1, 0x018518cf}, {1, 0x0186370b}, {1, 0x0186ef77}, {5, 0x01867169},
165 {5, 0x01891212}, {1, 0x01894126}, {1, 0x018b5f43}, {2, 0x018e5a9f},
166 {2, 0x018df690}, {1, 0x018f6ef1}, {2, 0x018dd6ec}, {1, 0x018e4acc},
167 {2, 0x01910d40}, {2, 0x0191cd46}, {1, 0x0191a3fb}, {1, 0x0193ad3d},
168 {1, 0x01935a45}, {5, 0x01945f12}, {1, 0x0196817e}, {1, 0x0197f5a4},
169 {1, 0x0199189a}, {1, 0x0198f075}, {1, 0x01988ec0}, {1, 0x0199a26e},
170 {1, 0x019b0f64}, {2, 0x019aeb8b}, {0, 0x019d464e}, {1, 0x019cb645},
171 {2, 0x019e7492}, {2, 0x019ec4b2}, {2, 0x01a059c5}, {1, 0x01a15c8d},
172 {1, 0x01a1c1de}, {1, 0x01a35e34}, {1, 0x01a42613}, {1, 0x01a315c1},
173 {1, 0x01a6136d}, {5, 0x01a4ed09}, {2, 0x01a3d3e2}, {1, 0x01a56163},
174 {1, 0x01a4b140}, {1, 0x01a75dff}, {2, 0x01a8445e}, {2, 0x01aa1963},
175 {4, 0x01a8b072}, {2, 0x01aa2810}, {1, 0x01ab5524}, {1, 0x01abc7e6},
176 {2, 0x01ab49ba}, {2, 0x01afc536}, {1, 0x01ae9fa1}, {2, 0x01af41c8},
177 {2, 0x01b0be8f}, {1, 0x01af032f}, {1, 0x01b2ce20}, {2, 0x01b23d60},
178 {2, 0x01b52c9c}, {1, 0x01b41f2d}, {2, 0x01b4bb56}, {2, 0x01b6535f},
179 {1, 0x01b559d1}, {2, 0x01b63797}, {1, 0x01b6a188}, {1, 0x01b6ef01},
180 {3, 0x01b742e4}, {2, 0x01b9d0c9}, {2, 0x01b909fd}, {1, 0x01b97990},
181 {2, 0x01be4857}, {1, 0x01bdb55a}, {2, 0x01bdb46f}, {2, 0x01be3d77},
182 {2, 0x01bf503e}, {2, 0x01beb04e}, {2, 0x01bf00c2}, {2, 0x01c34b6f},
183 {1, 0x01c3f337}, {2, 0x01c568ea}, {2, 0x01c6bafb}, {1, 0x01c7f571},
184 {2, 0x01c7630d}, {1, 0x01c8360c}, {2, 0x01c8f730}, {1, 0x01ca19e8},
185 {1, 0x01cb719c}, {3, 0x01cfc1a7}, {2, 0x01d1f198}, {5, 0x01d106ca},
186 {1, 0x01d3c805}, {5, 0x01d55380}, {1, 0x01d60c07}, {1, 0x01d87f3d},
187 {1, 0x01d977a5}, {2, 0x01db79fd}, {1, 0x01ddc7ec}, {1, 0x01e041e9},
188 {1, 0x01e01084}, {1, 0x01e228ce}, {5, 0x01e5386d}, {5, 0x01e6f35e},
189 {1, 0x01e9dac0}, {1, 0x01e9185d}, {6, 0x01e93c13}, {2, 0x01e90352},
190 {2, 0x01ea4add}, {1, 0x01ea5884}, {1, 0x01eacdc6}, {1, 0x01ec02a3},
191 {2, 0x01ec6ca1}, {2, 0x01edd3b8}, {1, 0x01eee113}, {1, 0x01ede61e},
192 {1, 0x01edd5a9}, {5, 0x01ef71ab}, {5, 0x01f3fe61}, {1, 0x01f43899},
193 {1, 0x01f45068}, {2, 0x01f7965c}, {2, 0x01f56398}, {1, 0x01f71b25},
194 {2, 0x01f6a0da}, {1, 0x01f850ee}, {2, 0x01fcde96}, {2, 0x01fce16e},
195 {1, 0x01ff1acb}, {1, 0x02041cf4}, {1, 0x0204836f}, {5, 0x0205be24},
196 {1, 0x0206413c}, {1, 0x020a65ee}, {1, 0x02081188}, {1, 0x020b6c15},
197 {1, 0x02085954}, {1, 0x0209426a}, {1, 0x020adb63}, {2, 0x020cf735},
198 {0, 0x020ed674}, {1, 0x0211fa9a}, {2, 0x02141c0b}, {2, 0x0213c1b0},
199 {2, 0x021a0e52}, {1, 0x0219e24e}, {1, 0x021a49ad}, {1, 0x021ab401},
200 {1, 0x021b6158}, {1, 0x021c9ad7}, {1, 0x021f9bbf}, {5, 0x0220bdb1},
201 {2, 0x0220c642}, {1, 0x0220f703}, {1, 0x022397a0}, {1, 0x022663a5},
202 {2, 0x022681d6}, {2, 0x0227a53a},
203 };
204
CreateBlockIndex(int nHeight)205 static CBlockIndex CreateBlockIndex(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
206 {
207 CBlockIndex index;
208 index.nHeight = nHeight;
209 index.pprev = ::ChainActive().Tip();
210 return index;
211 }
212
213 // Test suite for ancestor feerate transaction selection.
214 // Implemented as an additional function, rather than a separate test case,
215 // to allow reusing the blockchain created in CreateNewBlock_validity.
TestPackageSelection(const CChainParams & chainparams,const CScript & scriptPubKey,const std::vector<CTransactionRef> & txFirst)216 void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector<CTransactionRef>& txFirst)
217 {
218 // Test the ancestor feerate transaction selection.
219 TestMemPoolEntryHelper entry;
220
221 // Test that a medium fee transaction will be selected after a higher fee
222 // rate package with a low fee rate parent.
223 CMutableTransaction tx;
224 tx.vin.resize(1);
225 tx.vin[0].scriptSig = CScript() << OP_1;
226 tx.vin[0].prevout.hash = txFirst[0]->GetHash();
227 tx.vin[0].prevout.n = 0;
228 tx.vout.resize(1);
229 tx.vout[0].nValue = 5000000000LL - 400000;
230 // This tx has a low fee: 1000 satoshis
231 uint256 hashParentTx = tx.GetHash(); // save this txid for later use
232 m_node.mempool->addUnchecked(entry.Fee(400000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
233
234 // This tx has a medium fee: 10000 satoshis
235 tx.vin[0].prevout.hash = txFirst[1]->GetHash();
236 tx.vout[0].nValue = 5000000000LL - 4000000;
237 uint256 hashMediumFeeTx = tx.GetHash();
238 m_node.mempool->addUnchecked(entry.Fee(4000000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
239
240 // This tx has a high fee, but depends on the first transaction
241 tx.vin[0].prevout.hash = hashParentTx;
242 tx.vout[0].nValue = 5000000000LL - 10000 - 400000 * 50; // 50k satoshi fee
243 uint256 hashHighFeeTx = tx.GetHash();
244 m_node.mempool->addUnchecked(entry.Fee(400000 * 50).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
245
246 std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
247 BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx);
248 BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx);
249 BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx);
250
251 // Test that a package below the block min tx fee doesn't get included
252 tx.vin[0].prevout.hash = hashHighFeeTx;
253 tx.vout[0].nValue = 5000000000LL - 10000 - 20000000; // 0 fee
254 uint256 hashFreeTx = tx.GetHash();
255 m_node.mempool->addUnchecked(entry.Fee(0).FromTx(tx));
256 size_t freeTxSize = ::GetSerializeSize(tx, PROTOCOL_VERSION);
257
258 // Calculate a fee on child transaction that will put the package just
259 // below the block min tx fee (assuming 1 child tx of the same size).
260 CAmount feeToUse = blockMinFeeRate.GetFee(2*freeTxSize) - 1;
261
262 tx.vin[0].prevout.hash = hashFreeTx;
263 tx.vout[0].nValue = 5000000000LL - 10000 - 20000000 - feeToUse;
264 uint256 hashLowFeeTx = tx.GetHash();
265 m_node.mempool->addUnchecked(entry.Fee(feeToUse).FromTx(tx));
266 pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
267 // Verify that the free tx and the low fee tx didn't get selected
268 for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
269 BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx);
270 BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx);
271 }
272
273 // Test that packages above the min relay fee do get included, even if one
274 // of the transactions is below the min relay fee
275 // Remove the low fee transaction and replace with a higher fee transaction
276 m_node.mempool->removeRecursive(CTransaction(tx), MemPoolRemovalReason::REPLACED);
277 tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee
278 hashLowFeeTx = tx.GetHash();
279 m_node.mempool->addUnchecked(entry.Fee(feeToUse+2).FromTx(tx));
280 pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
281 BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx);
282 BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx);
283
284 // Test that transaction selection properly updates ancestor fee
285 // calculations as ancestor transactions get included in a block.
286 // Add a 0-fee transaction that has 2 outputs.
287 tx.vin[0].prevout.hash = txFirst[2]->GetHash();
288 tx.vout.resize(2);
289 tx.vout[0].nValue = 5000000000LL - 100000000;
290 tx.vout[1].nValue = 100000000; // 1BTC output
291 uint256 hashFreeTx2 = tx.GetHash();
292 m_node.mempool->addUnchecked(entry.Fee(0).SpendsCoinbase(true).FromTx(tx));
293
294 // This tx can't be mined by itself
295 tx.vin[0].prevout.hash = hashFreeTx2;
296 tx.vout.resize(1);
297 feeToUse = blockMinFeeRate.GetFee(freeTxSize);
298 tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
299 uint256 hashLowFeeTx2 = tx.GetHash();
300 m_node.mempool->addUnchecked(entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
301 pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
302
303 // Verify that this tx isn't selected.
304 for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
305 BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx2);
306 BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx2);
307 }
308
309 // This tx will be mineable, and should cause hashLowFeeTx2 to be selected
310 // as well.
311 tx.vin[0].prevout.n = 1;
312 tx.vout[0].nValue = 100000000 - 4000000; // 10k satoshi fee
313 m_node.mempool->addUnchecked(entry.Fee(4000000).FromTx(tx));
314 pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
315 BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2);
316 }
317
calculateReward(const CBlock & block)318 CAmount calculateReward(const CBlock& block){
319 CAmount sumVout = 0, fee = 0;
320 for(const CTransactionRef t : block.vtx){
321 fee += ::ChainstateActive().CoinsTip().GetValueIn(*t);
322 sumVout += t->GetValueOut();
323 }
324 return sumVout - fee;
325 }
326
327 // NOTE: These tests rely on CreateNewBlock doing its own self-validation!
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)328 BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
329 {
330 // Note that by default, these tests run with size accounting enabled.
331 const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
332 const CChainParams& chainparams = *chainParams;
333 const Consensus::Params& consensusParams = chainparams.GetConsensus();
334 CScript scriptPubKey = CScript() << ParseHex("040d61d8653448c98731ee5fffd303c15e71ec2057b77f11ab3601979728cdaff2d68afbba14e4fa0bc44f2072b0b23ef63717f8cdfbe58dcd33f32b6afe98741a") << OP_CHECKSIG;
335 std::unique_ptr<CBlockTemplate> pblocktemplate;
336 CMutableTransaction tx;
337 CScript script;
338 uint256 hash;
339 TestMemPoolEntryHelper entry;
340 entry.nFee = 11;
341 entry.nHeight = 11;
342
343 fCheckpointsEnabled = false;
344
345 // Simple block creation, nothing special yet:
346 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
347
348 // We can't make transactions until we have inputs
349 // Therefore, load 550 blocks :)
350 static_assert(sizeof(blockinfo) / sizeof(*blockinfo) == 550, "Should have 550 blocks to import");
351 int baseheight = 0;
352 std::vector<CTransactionRef> txFirst;
353 for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
354 {
355 CBlock *pblock = &pblocktemplate->block; // pointer for convenience
356 {
357 LOCK(cs_main);
358 pblock->nVersion = 4; //use version 4 as we enable BIP34, BIP65 and BIP66 since genesis
359 pblock->nTime = ::ChainActive().Tip()->GetMedianTimePast()+1+i;
360 CMutableTransaction txCoinbase(*pblock->vtx[0]);
361 txCoinbase.nVersion = 1;
362 txCoinbase.vin[0].scriptSig = CScript();
363 txCoinbase.vin[0].scriptSig = CScript() << ::ChainActive().Height()+1 << blockinfo[i].extranonce;
364 txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
365 txCoinbase.vout[0].scriptPubKey = CScript();
366 pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
367 if (txFirst.size() == 0)
368 baseheight = ::ChainActive().Height();
369 if (txFirst.size() < 4)
370 txFirst.push_back(pblock->vtx[0]);
371 pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
372 pblock->nNonce = blockinfo[i].nonce;
373 }
374 std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
375 BOOST_CHECK(ProcessNewBlock(chainparams, shared_pblock, true, nullptr));
376 pblock->hashPrevBlock = pblock->GetHash();
377 }
378
379 LOCK(cs_main);
380 LOCK(m_node.mempool->cs);
381
382 // Just to make sure we can still make simple blocks
383 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
384
385 const CAmount BLOCKSUBSIDY = 50*COIN;
386 const CAmount LOWFEE = CENT;
387 const CAmount HIGHFEE = COIN;
388 const CAmount HIGHERFEE = 4*COIN;
389
390 // block sigops > limit: 1000 CHECKMULTISIG + 1
391 tx.vin.resize(1);
392 // NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
393 tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1;
394 tx.vin[0].prevout.hash = txFirst[0]->GetHash();
395 tx.vin[0].prevout.n = 0;
396 tx.vout.resize(1);
397 tx.vout[0].nValue = BLOCKSUBSIDY;
398 for (unsigned int i = 0; i < 1001; ++i)
399 {
400 tx.vout[0].nValue -= LOWFEE;
401 hash = tx.GetHash();
402 bool spendsCoinbase = i == 0; // only first tx spends coinbase
403 // If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
404 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
405 tx.vin[0].prevout.hash = hash;
406 }
407
408 BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-blk-sigops"));
409 m_node.mempool->clear();
410
411 tx.vin[0].prevout.hash = txFirst[0]->GetHash();
412 tx.vout[0].nValue = BLOCKSUBSIDY;
413 for (unsigned int i = 0; i < 1001; ++i)
414 {
415 tx.vout[0].nValue -= LOWFEE;
416 hash = tx.GetHash();
417 bool spendsCoinbase = i == 0; // only first tx spends coinbase
418 // If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
419 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx));
420 tx.vin[0].prevout.hash = hash;
421 }
422 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
423 m_node.mempool->clear();
424
425 // block size > limit
426 tx.vin[0].scriptSig = CScript();
427 // 18 * (520char + DROP) + OP_1 = 9433 bytes
428 std::vector<unsigned char> vchData(52);
429 for (unsigned int i = 0; i < 18; ++i)
430 tx.vin[0].scriptSig << vchData << OP_DROP;
431 tx.vin[0].scriptSig << OP_1;
432 tx.vin[0].prevout.hash = txFirst[0]->GetHash();
433 tx.vout[0].nValue = BLOCKSUBSIDY;
434 for (unsigned int i = 0; i < 128; ++i)
435 {
436 tx.vout[0].nValue -= LOWFEE;
437 hash = tx.GetHash();
438 bool spendsCoinbase = i == 0; // only first tx spends coinbase
439 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
440 tx.vin[0].prevout.hash = hash;
441 }
442 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
443 m_node.mempool->clear();
444
445 // orphan in *m_node.mempool, template creation fails
446 hash = tx.GetHash();
447 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
448 BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
449 m_node.mempool->clear();
450
451 // child with higher feerate than parent
452 tx.vin[0].scriptSig = CScript() << OP_1;
453 tx.vin[0].prevout.hash = txFirst[1]->GetHash();
454 tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
455 hash = tx.GetHash();
456 m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
457 tx.vin[0].prevout.hash = hash;
458 tx.vin.resize(2);
459 tx.vin[1].scriptSig = CScript() << OP_1;
460 tx.vin[1].prevout.hash = txFirst[0]->GetHash();
461 tx.vin[1].prevout.n = 0;
462 tx.vout[0].nValue = tx.vout[0].nValue+BLOCKSUBSIDY-HIGHERFEE; //First txn output + fresh coinbase - new txn fee
463 hash = tx.GetHash();
464 m_node.mempool->addUnchecked(entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
465 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
466 m_node.mempool->clear();
467
468 // coinbase in *m_node.mempool, template creation fails
469 tx.vin.resize(1);
470 tx.vin[0].prevout.SetNull();
471 tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
472 tx.vout[0].nValue = 0;
473 hash = tx.GetHash();
474 // give it a fee so it'll get mined
475 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
476 // Should throw bad-cb-multiple
477 BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple"));
478 m_node.mempool->clear();
479
480 // double spend txn pair in *m_node.mempool, template creation fails
481 tx.vin[0].prevout.hash = txFirst[0]->GetHash();
482 tx.vin[0].scriptSig = CScript() << OP_1;
483 tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
484 tx.vout[0].scriptPubKey = CScript() << OP_1;
485 hash = tx.GetHash();
486 m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
487 tx.vout[0].scriptPubKey = CScript() << OP_2;
488 hash = tx.GetHash();
489 m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
490 BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
491 m_node.mempool->clear();
492
493 // subsidy changing
494 int nHeight = ::ChainActive().Height();
495 // Create an actual 209999-long block chain (without valid blocks).
496 while (::ChainActive().Tip()->nHeight < 1427002) {
497 CBlockIndex* prev = ::ChainActive().Tip();
498 CBlockIndex* next = new CBlockIndex();
499 next->phashBlock = new uint256(InsecureRand256());
500 ::ChainstateActive().CoinsTip().SetBestBlock(next->GetBlockHash());
501 next->pprev = prev;
502 next->nHeight = prev->nHeight + 1;
503 next->BuildSkip();
504 ::ChainActive().SetTip(next);
505 }
506 int blocktimeDownscaleFactor = consensusParams.BlocktimeDownscaleFactor(::ChainActive().Tip()->nHeight + 1);
507 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey, true, true));
508 BOOST_CHECK(calculateReward(pblocktemplate->block) == 400000000/blocktimeDownscaleFactor);
509 // Extend to a 210000-long block chain.
510 while (::ChainActive().Tip()->nHeight < 1427004) {
511 CBlockIndex* prev = ::ChainActive().Tip();
512 CBlockIndex* next = new CBlockIndex();
513 next->phashBlock = new uint256(InsecureRand256());
514 ::ChainstateActive().CoinsTip().SetBestBlock(next->GetBlockHash());
515 next->pprev = prev;
516 next->nHeight = prev->nHeight + 1;
517 next->BuildSkip();
518 ::ChainActive().SetTip(next);
519 }
520
521 blocktimeDownscaleFactor = consensusParams.BlocktimeDownscaleFactor(::ChainActive().Tip()->nHeight + 1);
522 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey, true, true));
523 BOOST_CHECK(calculateReward(pblocktemplate->block) == 200000000/blocktimeDownscaleFactor);
524
525 // invalid p2sh txn in *m_node.mempool, template creation fails
526 tx.vin[0].prevout.hash = txFirst[0]->GetHash();
527 tx.vin[0].prevout.n = 0;
528 tx.vin[0].scriptSig = CScript() << OP_1;
529 tx.vout[0].nValue = BLOCKSUBSIDY-LOWFEE;
530 script = CScript() << OP_0;
531 tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
532 hash = tx.GetHash();
533 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
534 tx.vin[0].prevout.hash = hash;
535 tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end());
536 tx.vout[0].nValue -= LOWFEE;
537 hash = tx.GetHash();
538 m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
539 // Should throw block-validation-failed
540 BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("TestBlockValidity failed"));
541 m_node.mempool->clear();
542
543 // Delete the dummy blocks again.
544 while (::ChainActive().Tip()->nHeight > nHeight) {
545 CBlockIndex* del = ::ChainActive().Tip();
546 ::ChainActive().SetTip(del->pprev);
547 ::ChainstateActive().CoinsTip().SetBestBlock(del->pprev->GetBlockHash());
548 delete del->phashBlock;
549 delete del;
550 }
551
552 // non-final txs in mempool
553 SetMockTime(::ChainActive().Tip()->GetMedianTimePast()+1);
554 int flags = LOCKTIME_VERIFY_SEQUENCE|LOCKTIME_MEDIAN_TIME_PAST;
555 // height map
556 std::vector<int> prevheights;
557
558 // relative height locked
559 tx.nVersion = 2;
560 tx.vin.resize(1);
561 prevheights.resize(1);
562 tx.vin[0].prevout.hash = txFirst[0]->GetHash(); // only 1 transaction
563 tx.vin[0].prevout.n = 0;
564 tx.vin[0].scriptSig = CScript() << OP_1;
565 tx.vin[0].nSequence = ::ChainActive().Tip()->nHeight + 1; // txFirst[0] is the 2nd block
566 prevheights[0] = baseheight + 1;
567 tx.vout.resize(1);
568 tx.vout[0].nValue = BLOCKSUBSIDY-HIGHFEE;
569 tx.vout[0].scriptPubKey = CScript() << OP_1;
570 tx.nLockTime = 0;
571 hash = tx.GetHash();
572 m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
573 BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
574 BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
575 BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, &prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 2))); // Sequence locks pass on 2nd block
576
577 // relative time locked
578 tx.vin[0].prevout.hash = txFirst[1]->GetHash();
579 tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((::ChainActive().Tip()->GetMedianTimePast()+1-::ChainActive()[1]->GetMedianTimePast()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1); // txFirst[1] is the 3rd block
580 prevheights[0] = baseheight + 2;
581 hash = tx.GetHash();
582 m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
583 BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
584 BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
585
586 for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
587 ::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
588 BOOST_CHECK(SequenceLocks(CTransaction(tx), flags, &prevheights, CreateBlockIndex(::ChainActive().Tip()->nHeight + 1))); // Sequence locks pass 512 seconds later
589 for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
590 ::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime -= 512; //undo tricked MTP
591
592 // absolute height locked
593 tx.vin[0].prevout.hash = txFirst[2]->GetHash();
594 tx.vin[0].nSequence = CTxIn::SEQUENCE_FINAL - 1;
595 prevheights[0] = baseheight + 3;
596 tx.nLockTime = ::ChainActive().Tip()->nHeight + 1;
597 hash = tx.GetHash();
598 m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
599 BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
600 BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
601 BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block
602
603 // absolute time locked
604 tx.vin[0].prevout.hash = txFirst[3]->GetHash();
605 tx.nLockTime = ::ChainActive().Tip()->GetMedianTimePast();
606 prevheights.resize(1);
607 prevheights[0] = baseheight + 4;
608 hash = tx.GetHash();
609 m_node.mempool->addUnchecked(entry.Time(GetTime()).FromTx(tx));
610 BOOST_CHECK(!CheckFinalTx(CTransaction(tx), flags)); // Locktime fails
611 BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
612 BOOST_CHECK(IsFinalTx(CTransaction(tx), ::ChainActive().Tip()->nHeight + 2, ::ChainActive().Tip()->GetMedianTimePast() + 1)); // Locktime passes 1 second later
613
614 // mempool-dependent transactions (not added)
615 tx.vin[0].prevout.hash = hash;
616 prevheights[0] = ::ChainActive().Tip()->nHeight + 1;
617 tx.nLockTime = 0;
618 tx.vin[0].nSequence = 0;
619 BOOST_CHECK(CheckFinalTx(CTransaction(tx), flags)); // Locktime passes
620 BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
621 tx.vin[0].nSequence = 1;
622 BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
623 tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG;
624 BOOST_CHECK(TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks pass
625 tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | 1;
626 BOOST_CHECK(!TestSequenceLocks(CTransaction(tx), flags)); // Sequence locks fail
627
628 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
629
630 // None of the of the absolute height/time locked tx should have made
631 // it into the template because we still check IsFinalTx in CreateNewBlock,
632 // but relative locked txs will if inconsistently added to mempool.
633 // For now these will still generate a valid template until BIP68 soft fork
634 BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3U);
635 // However if we advance height by 1 and time by 512, all of them should be mined
636 for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++)
637 ::ChainActive().Tip()->GetAncestor(::ChainActive().Tip()->nHeight - i)->nTime += 512; //Trick the MedianTimePast
638 ::ChainActive().Tip()->nHeight++;
639 SetMockTime(::ChainActive().Tip()->GetMedianTimePast() + 1);
640
641 BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
642 BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5U);
643
644 ::ChainActive().Tip()->nHeight--;
645 SetMockTime(0);
646 m_node.mempool->clear();
647
648 TestPackageSelection(chainparams, scriptPubKey, txFirst);
649
650 fCheckpointsEnabled = true;
651 }
652
653 BOOST_AUTO_TEST_SUITE_END()
654