@@ -116,19 +116,19 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
116
116
tx.vout [0 ].nValue = 5000000000LL - 1000 ;
117
117
// This tx has a low fee: 1000 satoshis
118
118
uint256 hashParentTx = tx.GetHash (); // save this txid for later use
119
- tx_mempool.addUnchecked (entry.Fee (1000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
119
+ tx_mempool.addUnchecked (entry.Fee (1000 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
120
120
121
121
// This tx has a medium fee: 10000 satoshis
122
122
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
123
123
tx.vout [0 ].nValue = 5000000000LL - 10000 ;
124
124
uint256 hashMediumFeeTx = tx.GetHash ();
125
- tx_mempool.addUnchecked (entry.Fee (10000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
125
+ tx_mempool.addUnchecked (entry.Fee (10000 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
126
126
127
127
// This tx has a high fee, but depends on the first transaction
128
128
tx.vin [0 ].prevout .hash = hashParentTx;
129
129
tx.vout [0 ].nValue = 5000000000LL - 1000 - 50000 ; // 50k satoshi fee
130
130
uint256 hashHighFeeTx = tx.GetHash ();
131
- tx_mempool.addUnchecked (entry.Fee (50000 ).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
131
+ tx_mempool.addUnchecked (entry.Fee (50000 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (false ).FromTx (tx));
132
132
133
133
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey);
134
134
BOOST_REQUIRE_EQUAL (pblocktemplate->block .vtx .size (), 4U );
@@ -239,7 +239,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
239
239
hash = tx.GetHash ();
240
240
bool spendsCoinbase = i == 0 ; // only first tx spends coinbase
241
241
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
242
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
242
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
243
243
tx.vin [0 ].prevout .hash = hash;
244
244
}
245
245
@@ -257,7 +257,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
257
257
hash = tx.GetHash ();
258
258
bool spendsCoinbase = i == 0 ; // only first tx spends coinbase
259
259
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
260
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).SigOpsCost (80 ).FromTx (tx));
260
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (spendsCoinbase).SigOpsCost (80 ).FromTx (tx));
261
261
tx.vin [0 ].prevout .hash = hash;
262
262
}
263
263
BOOST_CHECK (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey));
@@ -281,7 +281,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
281
281
tx.vout [0 ].nValue -= LOWFEE;
282
282
hash = tx.GetHash ();
283
283
bool spendsCoinbase = i == 0 ; // only first tx spends coinbase
284
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
284
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
285
285
tx.vin [0 ].prevout .hash = hash;
286
286
}
287
287
BOOST_CHECK (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey));
@@ -293,7 +293,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
293
293
294
294
// orphan in tx_mempool, template creation fails
295
295
hash = tx.GetHash ();
296
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).FromTx (tx));
296
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).FromTx (tx));
297
297
BOOST_CHECK_EXCEPTION (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
298
298
}
299
299
@@ -306,15 +306,15 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
306
306
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
307
307
tx.vout [0 ].nValue = BLOCKSUBSIDY - HIGHFEE;
308
308
hash = tx.GetHash ();
309
- tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
309
+ tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
310
310
tx.vin [0 ].prevout .hash = hash;
311
311
tx.vin .resize (2 );
312
312
tx.vin [1 ].scriptSig = CScript () << OP_1;
313
313
tx.vin [1 ].prevout .hash = txFirst[0 ]->GetHash ();
314
314
tx.vin [1 ].prevout .n = 0 ;
315
315
tx.vout [0 ].nValue = tx.vout [0 ].nValue + BLOCKSUBSIDY - HIGHERFEE; // First txn output + fresh coinbase - new txn fee
316
316
hash = tx.GetHash ();
317
- tx_mempool.addUnchecked (entry.Fee (HIGHERFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
317
+ tx_mempool.addUnchecked (entry.Fee (HIGHERFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
318
318
BOOST_CHECK (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey));
319
319
}
320
320
@@ -329,7 +329,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
329
329
tx.vout [0 ].nValue = 0 ;
330
330
hash = tx.GetHash ();
331
331
// give it a fee so it'll get mined
332
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
332
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (false ).FromTx (tx));
333
333
// Should throw bad-cb-multiple
334
334
BOOST_CHECK_EXCEPTION (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-cb-multiple" ));
335
335
}
@@ -344,10 +344,10 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
344
344
tx.vout [0 ].nValue = BLOCKSUBSIDY - HIGHFEE;
345
345
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
346
346
hash = tx.GetHash ();
347
- tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
347
+ tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
348
348
tx.vout [0 ].scriptPubKey = CScript () << OP_2;
349
349
hash = tx.GetHash ();
350
- tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
350
+ tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
351
351
BOOST_CHECK_EXCEPTION (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" bad-txns-inputs-missingorspent" ));
352
352
}
353
353
@@ -390,12 +390,12 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
390
390
CScript script = CScript () << OP_0;
391
391
tx.vout [0 ].scriptPubKey = GetScriptForDestination (ScriptHash (script));
392
392
hash = tx.GetHash ();
393
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
393
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
394
394
tx.vin [0 ].prevout .hash = hash;
395
395
tx.vin [0 ].scriptSig = CScript () << std::vector<unsigned char >(script.begin (), script.end ());
396
396
tx.vout [0 ].nValue -= LOWFEE;
397
397
hash = tx.GetHash ();
398
- tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
398
+ tx_mempool.addUnchecked (entry.Fee (LOWFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (false ).FromTx (tx));
399
399
// Should throw block-validation-failed
400
400
BOOST_CHECK_EXCEPTION (AssemblerForTest (tx_mempool).CreateNewBlock (scriptPubKey), std::runtime_error, HasReason (" block-validation-failed" ));
401
401
@@ -432,7 +432,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
432
432
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
433
433
tx.nLockTime = 0 ;
434
434
hash = tx.GetHash ();
435
- tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
435
+ tx_mempool.addUnchecked (entry.Fee (HIGHFEE).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
436
436
BOOST_CHECK (CheckFinalTxAtTip (*Assert (m_node.chainman ->ActiveChain ().Tip ()), CTransaction{tx})); // Locktime passes
437
437
BOOST_CHECK (!TestSequenceLocks (CTransaction{tx}, tx_mempool)); // Sequence locks fail
438
438
@@ -446,7 +446,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
446
446
tx.vin [0 ].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((m_node.chainman ->ActiveChain ().Tip ()->GetMedianTimePast ()+1 -m_node.chainman ->ActiveChain ()[1 ]->GetMedianTimePast ()) >> CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1 ); // txFirst[1] is the 3rd block
447
447
prevheights[0 ] = baseheight + 2 ;
448
448
hash = tx.GetHash ();
449
- tx_mempool.addUnchecked (entry.Time (GetTime ()).FromTx (tx));
449
+ tx_mempool.addUnchecked (entry.Time (Now<NodeSeconds> ()).FromTx (tx));
450
450
BOOST_CHECK (CheckFinalTxAtTip (*Assert (m_node.chainman ->ActiveChain ().Tip ()), CTransaction{tx})); // Locktime passes
451
451
BOOST_CHECK (!TestSequenceLocks (CTransaction{tx}, tx_mempool)); // Sequence locks fail
452
452
@@ -469,7 +469,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
469
469
prevheights[0 ] = baseheight + 3 ;
470
470
tx.nLockTime = m_node.chainman ->ActiveChain ().Tip ()->nHeight + 1 ;
471
471
hash = tx.GetHash ();
472
- tx_mempool.addUnchecked (entry.Time (GetTime ()).FromTx (tx));
472
+ tx_mempool.addUnchecked (entry.Time (Now<NodeSeconds> ()).FromTx (tx));
473
473
BOOST_CHECK (!CheckFinalTxAtTip (*Assert (m_node.chainman ->ActiveChain ().Tip ()), CTransaction{tx})); // Locktime fails
474
474
BOOST_CHECK (TestSequenceLocks (CTransaction{tx}, tx_mempool)); // Sequence locks pass
475
475
BOOST_CHECK (IsFinalTx (CTransaction (tx), m_node.chainman ->ActiveChain ().Tip ()->nHeight + 2 , m_node.chainman ->ActiveChain ().Tip ()->GetMedianTimePast ())); // Locktime passes on 2nd block
@@ -480,7 +480,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
480
480
prevheights.resize (1 );
481
481
prevheights[0 ] = baseheight + 4 ;
482
482
hash = tx.GetHash ();
483
- tx_mempool.addUnchecked (entry.Time (GetTime ()).FromTx (tx));
483
+ tx_mempool.addUnchecked (entry.Time (Now<NodeSeconds> ()).FromTx (tx));
484
484
BOOST_CHECK (!CheckFinalTxAtTip (*Assert (m_node.chainman ->ActiveChain ().Tip ()), CTransaction{tx})); // Locktime fails
485
485
BOOST_CHECK (TestSequenceLocks (CTransaction{tx}, tx_mempool)); // Sequence locks pass
486
486
BOOST_CHECK (IsFinalTx (CTransaction (tx), m_node.chainman ->ActiveChain ().Tip ()->nHeight + 2 , m_node.chainman ->ActiveChain ().Tip ()->GetMedianTimePast () + 1 )); // Locktime passes 1 second later
@@ -535,28 +535,28 @@ void MinerTestingSetup::TestPrioritisedMining(const CScript& scriptPubKey, const
535
535
tx.vout .resize (1 );
536
536
tx.vout [0 ].nValue = 5000000000LL ; // 0 fee
537
537
uint256 hashFreePrioritisedTx = tx.GetHash ();
538
- tx_mempool.addUnchecked (entry.Fee (0 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
538
+ tx_mempool.addUnchecked (entry.Fee (0 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
539
539
tx_mempool.PrioritiseTransaction (hashFreePrioritisedTx, 5 * COIN);
540
540
541
541
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
542
542
tx.vin [0 ].prevout .n = 0 ;
543
543
tx.vout [0 ].nValue = 5000000000LL - 1000 ;
544
544
// This tx has a low fee: 1000 satoshis
545
545
uint256 hashParentTx = tx.GetHash (); // save this txid for later use
546
- tx_mempool.addUnchecked (entry.Fee (1000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
546
+ tx_mempool.addUnchecked (entry.Fee (1000 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
547
547
548
548
// This tx has a medium fee: 10000 satoshis
549
549
tx.vin [0 ].prevout .hash = txFirst[2 ]->GetHash ();
550
550
tx.vout [0 ].nValue = 5000000000LL - 10000 ;
551
551
uint256 hashMediumFeeTx = tx.GetHash ();
552
- tx_mempool.addUnchecked (entry.Fee (10000 ).Time (GetTime ()).SpendsCoinbase (true ).FromTx (tx));
552
+ tx_mempool.addUnchecked (entry.Fee (10000 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (true ).FromTx (tx));
553
553
tx_mempool.PrioritiseTransaction (hashMediumFeeTx, -5 * COIN);
554
554
555
555
// This tx also has a low fee, but is prioritised
556
556
tx.vin [0 ].prevout .hash = hashParentTx;
557
557
tx.vout [0 ].nValue = 5000000000LL - 1000 - 1000 ; // 1000 satoshi fee
558
558
uint256 hashPrioritsedChild = tx.GetHash ();
559
- tx_mempool.addUnchecked (entry.Fee (1000 ).Time (GetTime ()).SpendsCoinbase (false ).FromTx (tx));
559
+ tx_mempool.addUnchecked (entry.Fee (1000 ).Time (Now<NodeSeconds> ()).SpendsCoinbase (false ).FromTx (tx));
560
560
tx_mempool.PrioritiseTransaction (hashPrioritsedChild, 2 * COIN);
561
561
562
562
// Test that transaction selection properly updates ancestor fee calculations as prioritised
0 commit comments