@@ -118,19 +118,19 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
118
118
tx.vout [0 ].nValue = 5000000000LL - 1000 ;
119
119
// This tx has a low fee: 1000 satoshis
120
120
uint256 hashParentTx = tx.GetHash (); // save this txid for later use
121
- mempool. addUnchecked (entry.Fee (1000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
121
+ m_node. mempool -> addUnchecked (entry.Fee (1000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
122
122
123
123
// This tx has a medium fee: 10000 satoshis
124
124
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
125
125
tx.vout [0 ].nValue = 5000000000LL - 10000 ;
126
126
uint256 hashMediumFeeTx = tx.GetHash ();
127
- mempool. addUnchecked (entry.Fee (10000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
127
+ m_node. mempool -> addUnchecked (entry.Fee (10000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
128
128
129
129
// This tx has a high fee, but depends on the first transaction
130
130
tx.vin [0 ].prevout .hash = hashParentTx;
131
131
tx.vout [0 ].nValue = 5000000000LL - 1000 - 50000 ; // 50k satoshi fee
132
132
uint256 hashHighFeeTx = tx.GetHash ();
133
- mempool. addUnchecked (entry.Fee (50000 ).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
133
+ m_node. mempool -> addUnchecked (entry.Fee (50000 ).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
134
134
135
135
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
136
136
BOOST_CHECK (pblocktemplate->block .vtx [1 ]->GetHash () == hashParentTx);
@@ -141,7 +141,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
141
141
tx.vin [0 ].prevout .hash = hashHighFeeTx;
142
142
tx.vout [0 ].nValue = 5000000000LL - 1000 - 50000 ; // 0 fee
143
143
uint256 hashFreeTx = tx.GetHash ();
144
- mempool. addUnchecked (entry.Fee (0 ).FromTx (tx));
144
+ m_node. mempool -> addUnchecked (entry.Fee (0 ).FromTx (tx));
145
145
size_t freeTxSize = ::GetSerializeSize (tx, PROTOCOL_VERSION);
146
146
147
147
// Calculate a fee on child transaction that will put the package just
@@ -151,7 +151,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
151
151
tx.vin [0 ].prevout .hash = hashFreeTx;
152
152
tx.vout [0 ].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
153
153
uint256 hashLowFeeTx = tx.GetHash ();
154
- mempool. addUnchecked (entry.Fee (feeToUse).FromTx (tx));
154
+ m_node. mempool -> addUnchecked (entry.Fee (feeToUse).FromTx (tx));
155
155
pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
156
156
// Verify that the free tx and the low fee tx didn't get selected
157
157
for (size_t i=0 ; i<pblocktemplate->block .vtx .size (); ++i) {
@@ -162,10 +162,10 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
162
162
// Test that packages above the min relay fee do get included, even if one
163
163
// of the transactions is below the min relay fee
164
164
// Remove the low fee transaction and replace with a higher fee transaction
165
- mempool. removeRecursive (CTransaction (tx), MemPoolRemovalReason::REPLACED);
165
+ m_node. mempool -> removeRecursive (CTransaction (tx), MemPoolRemovalReason::REPLACED);
166
166
tx.vout [0 ].nValue -= 2 ; // Now we should be just over the min relay fee
167
167
hashLowFeeTx = tx.GetHash ();
168
- mempool. addUnchecked (entry.Fee (feeToUse+2 ).FromTx (tx));
168
+ m_node. mempool -> addUnchecked (entry.Fee (feeToUse+2 ).FromTx (tx));
169
169
pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
170
170
BOOST_CHECK (pblocktemplate->block .vtx [4 ]->GetHash () == hashFreeTx);
171
171
BOOST_CHECK (pblocktemplate->block .vtx [5 ]->GetHash () == hashLowFeeTx);
@@ -178,15 +178,15 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
178
178
tx.vout [0 ].nValue = 5000000000LL - 100000000 ;
179
179
tx.vout [1 ].nValue = 100000000 ; // 1BTC output
180
180
uint256 hashFreeTx2 = tx.GetHash ();
181
- mempool. addUnchecked (entry.Fee (0 ).SpendsCoinbase (true ).FromTx (tx));
181
+ m_node. mempool -> addUnchecked (entry.Fee (0 ).SpendsCoinbase (true ).FromTx (tx));
182
182
183
183
// This tx can't be mined by itself
184
184
tx.vin [0 ].prevout .hash = hashFreeTx2;
185
185
tx.vout .resize (1 );
186
186
feeToUse = blockMinFeeRate.GetFee (freeTxSize);
187
187
tx.vout [0 ].nValue = 5000000000LL - 100000000 - feeToUse;
188
188
uint256 hashLowFeeTx2 = tx.GetHash ();
189
- mempool. addUnchecked (entry.Fee (feeToUse).SpendsCoinbase (false ).FromTx (tx));
189
+ m_node. mempool -> addUnchecked (entry.Fee (feeToUse).SpendsCoinbase (false ).FromTx (tx));
190
190
pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
191
191
192
192
// Verify that this tx isn't selected.
@@ -199,7 +199,7 @@ void MinerTestingSetup::TestPackageSelection(const CChainParams& chainparams, co
199
199
// as well.
200
200
tx.vin [0 ].prevout .n = 1 ;
201
201
tx.vout [0 ].nValue = 100000000 - 10000 ; // 10k satoshi fee
202
- mempool. addUnchecked (entry.Fee (10000 ).FromTx (tx));
202
+ m_node. mempool -> addUnchecked (entry.Fee (10000 ).FromTx (tx));
203
203
pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey);
204
204
BOOST_CHECK (pblocktemplate->block .vtx [8 ]->GetHash () == hashLowFeeTx2);
205
205
}
@@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
256
256
}
257
257
258
258
LOCK (cs_main);
259
- LOCK (::mempool. cs );
259
+ LOCK (m_node. mempool -> cs );
260
260
261
261
// Just to make sure we can still make simple blocks
262
262
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
@@ -280,12 +280,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
280
280
hash = tx.GetHash ();
281
281
bool spendsCoinbase = i == 0 ; // only first tx spends coinbase
282
282
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
283
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
283
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
284
284
tx.vin [0 ].prevout .hash = hash;
285
285
}
286
286
287
287
BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-blk-sigops" ));
288
- mempool. clear ();
288
+ m_node. mempool -> clear ();
289
289
290
290
tx.vin [0 ].prevout .hash = txFirst[0 ]->GetHash ();
291
291
tx.vout [0 ].nValue = BLOCKSUBSIDY;
@@ -295,11 +295,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
295
295
hash = tx.GetHash ();
296
296
bool spendsCoinbase = i == 0 ; // only first tx spends coinbase
297
297
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
298
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).SigOpsCost (80 ).FromTx (tx));
298
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).SigOpsCost (80 ).FromTx (tx));
299
299
tx.vin [0 ].prevout .hash = hash;
300
300
}
301
301
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
302
- mempool. clear ();
302
+ m_node. mempool -> clear ();
303
303
304
304
// block size > limit
305
305
tx.vin [0 ].scriptSig = CScript ();
@@ -315,59 +315,59 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
315
315
tx.vout [0 ].nValue -= LOWFEE;
316
316
hash = tx.GetHash ();
317
317
bool spendsCoinbase = i == 0 ; // only first tx spends coinbase
318
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
318
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
319
319
tx.vin [0 ].prevout .hash = hash;
320
320
}
321
321
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
322
- mempool. clear ();
322
+ m_node. mempool -> clear ();
323
323
324
- // orphan in mempool, template creation fails
324
+ // orphan in *m_node. mempool, template creation fails
325
325
hash = tx.GetHash ();
326
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).FromTx (tx));
326
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).FromTx (tx));
327
327
BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
328
- mempool. clear ();
328
+ m_node. mempool -> clear ();
329
329
330
330
// child with higher feerate than parent
331
331
tx.vin [0 ].scriptSig = CScript () << OP_1;
332
332
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
333
333
tx.vout [0 ].nValue = BLOCKSUBSIDY-HIGHFEE;
334
334
hash = tx.GetHash ();
335
- mempool. addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
335
+ m_node. mempool -> addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
336
336
tx.vin [0 ].prevout .hash = hash;
337
337
tx.vin .resize (2 );
338
338
tx.vin [1 ].scriptSig = CScript () << OP_1;
339
339
tx.vin [1 ].prevout .hash = txFirst[0 ]->GetHash ();
340
340
tx.vin [1 ].prevout .n = 0 ;
341
341
tx.vout [0 ].nValue = tx.vout [0 ].nValue +BLOCKSUBSIDY-HIGHERFEE; // First txn output + fresh coinbase - new txn fee
342
342
hash = tx.GetHash ();
343
- mempool. addUnchecked (entry.Fee (HIGHERFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
343
+ m_node. mempool -> addUnchecked (entry.Fee (HIGHERFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
344
344
BOOST_CHECK (pblocktemplate = AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey));
345
- mempool. clear ();
345
+ m_node. mempool -> clear ();
346
346
347
- // coinbase in mempool, template creation fails
347
+ // coinbase in *m_node. mempool, template creation fails
348
348
tx.vin .resize (1 );
349
349
tx.vin [0 ].prevout .SetNull ();
350
350
tx.vin [0 ].scriptSig = CScript () << OP_0 << OP_1;
351
351
tx.vout [0 ].nValue = 0 ;
352
352
hash = tx.GetHash ();
353
353
// give it a fee so it'll get mined
354
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
354
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
355
355
// Should throw bad-cb-multiple
356
356
BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-cb-multiple" ));
357
- mempool. clear ();
357
+ m_node. mempool -> clear ();
358
358
359
- // double spend txn pair in mempool, template creation fails
359
+ // double spend txn pair in *m_node. mempool, template creation fails
360
360
tx.vin [0 ].prevout .hash = txFirst[0 ]->GetHash ();
361
361
tx.vin [0 ].scriptSig = CScript () << OP_1;
362
362
tx.vout [0 ].nValue = BLOCKSUBSIDY-HIGHFEE;
363
363
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
364
364
hash = tx.GetHash ();
365
- mempool. addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
365
+ m_node. mempool -> addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
366
366
tx.vout [0 ].scriptPubKey = CScript () << OP_2;
367
367
hash = tx.GetHash ();
368
- mempool. addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
368
+ m_node. mempool -> addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
369
369
BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
370
- mempool. clear ();
370
+ m_node. mempool -> clear ();
371
371
372
372
// subsidy changing
373
373
int nHeight = ::ChainActive ().Height ();
@@ -396,23 +396,23 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
396
396
}
397
397
BOOST_CHECK (pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
398
398
399
- // invalid p2sh txn in mempool, template creation fails
399
+ // invalid p2sh txn in *m_node. mempool, template creation fails
400
400
tx.vin[0 ].prevout.hash = txFirst[0 ]->GetHash ();
401
401
tx.vin[0 ].prevout.n = 0 ;
402
402
tx.vin[0 ].scriptSig = CScript() << OP_1;
403
403
tx.vout [0 ].nValue = BLOCKSUBSIDY-LOWFEE;
404
404
script = CScript () << OP_0;
405
405
tx.vout [0 ].scriptPubKey = GetScriptForDestination (ScriptHash (script));
406
406
hash = tx.GetHash ();
407
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
407
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
408
408
tx.vin [0 ].prevout .hash = hash;
409
409
tx.vin [0 ].scriptSig = CScript () << std::vector<unsigned char >(script.begin (), script.end ());
410
410
tx.vout [0 ].nValue -= LOWFEE;
411
411
hash = tx.GetHash ();
412
- mempool. addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
412
+ m_node. mempool -> addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
413
413
// Should throw block-validation-failed
414
414
BOOST_CHECK_EXCEPTION (AssemblerForTest (chainparams).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" block-validation-failed" ));
415
- mempool. clear ();
415
+ m_node. mempool -> clear ();
416
416
417
417
// Delete the dummy blocks again.
418
418
while (::ChainActive ().Tip ()->nHeight > nHeight) {
@@ -443,7 +443,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
443
443
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
444
444
tx.nLockTime = 0 ;
445
445
hash = tx.GetHash ();
446
- mempool. addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
446
+ m_node. mempool -> addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
447
447
BOOST_CHECK (CheckFinalTx (CTransaction (tx), flags)); // Locktime passes
448
448
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
449
449
BOOST_CHECK (SequenceLocks (CTransaction (tx), flags, &prevheights, CreateBlockIndex (::ChainActive ().Tip ()->nHeight + 2 ))); // Sequence locks pass on 2nd block
@@ -453,7 +453,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
453
453
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
454
454
prevheights[0 ] = baseheight + 2 ;
455
455
hash = tx.GetHash ();
456
- mempool. addUnchecked (entry.Time (GetTime ()).FromTx (tx));
456
+ m_node. mempool -> addUnchecked (entry.Time (GetTime ()).FromTx (tx));
457
457
BOOST_CHECK (CheckFinalTx (CTransaction (tx), flags)); // Locktime passes
458
458
BOOST_CHECK (!TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks fail
459
459
@@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
469
469
prevheights[0 ] = baseheight + 3 ;
470
470
tx.nLockTime = ::ChainActive ().Tip ()->nHeight + 1 ;
471
471
hash = tx.GetHash ();
472
- mempool. addUnchecked (entry.Time (GetTime ()).FromTx (tx));
472
+ m_node. mempool -> addUnchecked (entry.Time (GetTime ()).FromTx (tx));
473
473
BOOST_CHECK (!CheckFinalTx (CTransaction (tx), flags)); // Locktime fails
474
474
BOOST_CHECK (TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks pass
475
475
BOOST_CHECK (IsFinalTx (CTransaction (tx), ::ChainActive ().Tip ()->nHeight + 2 , ::ChainActive ().Tip ()->GetMedianTimePast ())); // Locktime passes on 2nd block
@@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
480
480
prevheights.resize (1 );
481
481
prevheights[0 ] = baseheight + 4 ;
482
482
hash = tx.GetHash ();
483
- mempool. addUnchecked (entry.Time (GetTime ()).FromTx (tx));
483
+ m_node. mempool -> addUnchecked (entry.Time (GetTime ()).FromTx (tx));
484
484
BOOST_CHECK (!CheckFinalTx (CTransaction (tx), flags)); // Locktime fails
485
485
BOOST_CHECK (TestSequenceLocks (CTransaction (tx), flags)); // Sequence locks pass
486
486
BOOST_CHECK (IsFinalTx (CTransaction (tx), ::ChainActive ().Tip ()->nHeight + 2 , ::ChainActive ().Tip ()->GetMedianTimePast () + 1 )); // Locktime passes 1 second later
@@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
517
517
518
518
::ChainActive ().Tip()->nHeight--;
519
519
SetMockTime (0 );
520
- mempool. clear ();
520
+ m_node. mempool -> clear ();
521
521
522
522
TestPackageSelection (chainparams, scriptPubKey, txFirst);
523
523
0 commit comments