MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_FIXTURE_TEST_CASE

Function BOOST_FIXTURE_TEST_CASE

src/test/rbf_tests.cpp:58–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58BOOST_FIXTURE_TEST_CASE(rbf_helper_functions, TestChain100Setup)
59{
60 CTxMemPool& pool = *Assert(m_node.mempool);
61 LOCK2(::cs_main, pool.cs);
62 TestMemPoolEntryHelper entry;
63
64 const CAmount low_fee{CENT/100};
65 const CAmount normal_fee{CENT/10};
66 const CAmount high_fee{CENT};
67
68 // Create a parent tx1 and child tx2 with normal fees:
69 const auto tx1 = make_tx(/*inputs=*/ {m_coinbase_txns[0]}, /*output_values=*/ {10 * COIN});
70 TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx1));
71 const auto tx2 = make_tx(/*inputs=*/ {tx1}, /*output_values=*/ {995 * CENT});
72 TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx2));
73
74 // Create a low-feerate parent tx3 and high-feerate child tx4 (cpfp)
75 const auto tx3 = make_tx(/*inputs=*/ {m_coinbase_txns[1]}, /*output_values=*/ {1099 * CENT});
76 TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx3));
77 const auto tx4 = make_tx(/*inputs=*/ {tx3}, /*output_values=*/ {999 * CENT});
78 TryAddToMempool(pool, entry.Fee(high_fee).FromTx(tx4));
79
80 // Create a parent tx5 and child tx6 where both have very low fees
81 const auto tx5 = make_tx(/*inputs=*/ {m_coinbase_txns[2]}, /*output_values=*/ {1099 * CENT});
82 TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx5));
83 const auto tx6 = make_tx(/*inputs=*/ {tx5}, /*output_values=*/ {1098 * CENT});
84 TryAddToMempool(pool, entry.Fee(low_fee).FromTx(tx6));
85 // Make tx6's modified fee much higher than its base fee. This should cause it to pass
86 // the fee-related checks despite being low-feerate.
87 pool.PrioritiseTransaction(tx6->GetHash(), 1 * COIN);
88
89 // Two independent high-feerate transactions, tx7 and tx8
90 const auto tx7 = make_tx(/*inputs=*/ {m_coinbase_txns[3]}, /*output_values=*/ {999 * CENT});
91 TryAddToMempool(pool, entry.Fee(high_fee).FromTx(tx7));
92 const auto tx8 = make_tx(/*inputs=*/ {m_coinbase_txns[4]}, /*output_values=*/ {999 * CENT});
93 TryAddToMempool(pool, entry.Fee(high_fee).FromTx(tx8));
94
95 // Will make these two parents of single child
96 const auto tx11 = make_tx(/*inputs=*/ {m_coinbase_txns[7]}, /*output_values=*/ {995 * CENT});
97 TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx11));
98 const auto tx12 = make_tx(/*inputs=*/ {m_coinbase_txns[8]}, /*output_values=*/ {995 * CENT});
99 TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx12));
100
101 // Will make two children of this single parent
102 const auto tx13 = make_tx(/*inputs=*/ {m_coinbase_txns[9]}, /*output_values=*/ {995 * CENT, 995 * CENT});
103 TryAddToMempool(pool, entry.Fee(normal_fee).FromTx(tx13));
104
105 const auto entry1_normal = pool.GetIter(tx1->GetHash()).value();
106 const auto entry2_normal = pool.GetIter(tx2->GetHash()).value();
107 const auto entry3_low = pool.GetIter(tx3->GetHash()).value();
108 const auto entry4_high = pool.GetIter(tx4->GetHash()).value();
109 const auto entry5_low = pool.GetIter(tx5->GetHash()).value();
110 const auto entry6_low_prioritised = pool.GetIter(tx6->GetHash()).value();
111 const auto entry7_high = pool.GetIter(tx7->GetHash()).value();
112 const auto entry8_high = pool.GetIter(tx8->GetHash()).value();
113
114 BOOST_CHECK_EQUAL(entry1_normal->GetFee(), normal_fee);
115 BOOST_CHECK_EQUAL(entry2_normal->GetFee(), normal_fee);

Callers

nothing calls this directly

Calls 15

TryAddToMempoolFunction · 0.85
GetRandHashFunction · 0.85
EntriesAndTxidsDisjointFunction · 0.85
PaysForRBFFunction · 0.85
MakeTransactionRefFunction · 0.85
GetEntriesForConflictsFunction · 0.85
ImprovesFeerateDiagramFunction · 0.85
FromTxMethod · 0.80
PrioritiseTransactionMethod · 0.80
GetIterMethod · 0.80
StageRemovalMethod · 0.80
StageAdditionMethod · 0.80

Tested by

no test coverage detected