@@ -277,6 +277,33 @@ BOOST_FIXTURE_TEST_CASE(miniminer_1p1c, TestChain100Setup)
277
277
278
278
BOOST_FIXTURE_TEST_CASE (miniminer_overlap, TestChain100Setup)
279
279
{
280
+ /* Tx graph for `miniminer_overlap` unit test:
281
+ *
282
+ * coinbase_tx [mined] ... block-chain
283
+ * -------------------------------------------------
284
+ * / | \ \ ... mempool
285
+ * / | \ |
286
+ * tx0 tx1 tx2 tx4
287
+ * [low] [med] [high] [high]
288
+ * \ | / |
289
+ * \ | / tx5
290
+ * \ | / [low]
291
+ * tx3 / \
292
+ * [high] tx6 tx7
293
+ * [med] [high]
294
+ *
295
+ * NOTE:
296
+ * -> "low"/"med"/"high" denote the _absolute_ fee of each tx
297
+ * -> tx3 has 3 inputs and 3 outputs, all other txs have 1 input and 2 outputs
298
+ * -> tx3's feerate is lower than tx2's, as tx3 has more weight (due to having more inputs and outputs)
299
+ *
300
+ * -> tx2_FR = high / tx2_vsize
301
+ * -> tx3_FR = high / tx3_vsize
302
+ * -> tx3_ASFR = (low+med+high+high) / (tx0_vsize + tx1_vsize + tx2_vsize + tx3_vsize)
303
+ * -> tx4_FR = high / tx4_vsize
304
+ * -> tx6_ASFR = (high+low+med) / (tx4_vsize + tx5_vsize + tx6_vsize)
305
+ * -> tx7_ASFR = (high+low+high) / (tx4_vsize + tx5_vsize + tx7_vsize) */
306
+
280
307
CTxMemPool& pool = *Assert (m_node.mempool );
281
308
LOCK2 (::cs_main, pool.cs );
282
309
TestMemPoolEntryHelper entry;
@@ -328,10 +355,16 @@ BOOST_FIXTURE_TEST_CASE(miniminer_overlap, TestChain100Setup)
328
355
const auto tx3_feerate = CFeeRate (high_fee, tx_vsizes[3 ]);
329
356
// tx3's feerate is lower than tx2's. same fee, different weight.
330
357
BOOST_CHECK (tx2_feerate > tx3_feerate);
331
- const auto tx3_anc_feerate = CFeeRate (low_fee + med_fee + high_fee, tx_vsizes[0 ] + tx_vsizes[1 ] + tx_vsizes[3 ]);
358
+ const auto tx3_anc_feerate = CFeeRate (low_fee + med_fee + high_fee + high_fee, tx_vsizes[0 ] + tx_vsizes[1 ] + tx_vsizes[2 ] + tx_vsizes[3 ]);
359
+ const auto tx3_iter = pool.GetIter (tx3->GetHash ());
360
+ BOOST_CHECK (tx3_anc_feerate == CFeeRate (tx3_iter.value ()->GetModFeesWithAncestors (), tx3_iter.value ()->GetSizeWithAncestors ()));
332
361
const auto tx4_feerate = CFeeRate (high_fee, tx_vsizes[4 ]);
333
- const auto tx6_anc_feerate = CFeeRate (low_fee + med_fee, tx_vsizes[5 ] + tx_vsizes[6 ]);
334
- const auto tx7_anc_feerate = CFeeRate (low_fee + high_fee, tx_vsizes[5 ] + tx_vsizes[7 ]);
362
+ const auto tx6_anc_feerate = CFeeRate (high_fee + low_fee + med_fee, tx_vsizes[4 ] + tx_vsizes[5 ] + tx_vsizes[6 ]);
363
+ const auto tx6_iter = pool.GetIter (tx6->GetHash ());
364
+ BOOST_CHECK (tx6_anc_feerate == CFeeRate (tx6_iter.value ()->GetModFeesWithAncestors (), tx6_iter.value ()->GetSizeWithAncestors ()));
365
+ const auto tx7_anc_feerate = CFeeRate (high_fee + low_fee + high_fee, tx_vsizes[4 ] + tx_vsizes[5 ] + tx_vsizes[7 ]);
366
+ const auto tx7_iter = pool.GetIter (tx7->GetHash ());
367
+ BOOST_CHECK (tx7_anc_feerate == CFeeRate (tx7_iter.value ()->GetModFeesWithAncestors (), tx7_iter.value ()->GetSizeWithAncestors ()));
335
368
BOOST_CHECK (tx4_feerate > tx6_anc_feerate);
336
369
BOOST_CHECK (tx4_feerate > tx7_anc_feerate);
337
370
@@ -445,12 +478,12 @@ BOOST_FIXTURE_TEST_CASE(calculate_cluster, TestChain100Setup)
445
478
const auto cluster_501 = pool.GatherClusters ({tx_501->GetHash ()});
446
479
BOOST_CHECK_EQUAL (cluster_501.size (), 0 );
447
480
448
- // Zig Zag cluster:
449
- // txp0 txp1 txp2 ... txp48 txp49
450
- // \ / \ / \ \ /
451
- // txc0 txc1 txc2 ... txc48
452
- // Note that each transaction's ancestor size is 1 or 3, and each descendant size is 1, 2 or 3.
453
- // However, all of these transactions are in the same cluster.
481
+ /* Zig Zag cluster:
482
+ * txp0 txp1 txp2 ... txp48 txp49
483
+ * \ / \ / \ \ /
484
+ * txc0 txc1 txc2 ... txc48
485
+ * Note that each transaction's ancestor size is 1 or 3, and each descendant size is 1, 2 or 3.
486
+ * However, all of these transactions are in the same cluster. */
454
487
std::vector<uint256> zigzag_txids;
455
488
for (auto p{0 }; p < 50 ; ++p) {
456
489
const auto txp = make_tx ({COutPoint{GetRandHash (), 0 }}, /* num_outputs=*/ 2 );
0 commit comments