Skip to content

Commit dfd6a37

Browse files
committed
[refactor] unify fee amounts in miniminer_tests
Name {low,med,high}_fee constants for reuse across file.
1 parent f4b1b24 commit dfd6a37

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/test/miniminer_tests.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
BOOST_FIXTURE_TEST_SUITE(miniminer_tests, TestingSetup)
1717

18+
const CAmount low_fee{CENT/2000}; // 500 ṩ
19+
const CAmount med_fee{CENT/200}; // 5000 ṩ
20+
const CAmount high_fee{CENT/10}; // 100_000 ṩ
21+
22+
1823
static inline CTransactionRef make_tx(const std::vector<COutPoint>& inputs, size_t num_outputs)
1924
{
2025
CMutableTransaction tx = CMutableTransaction();
@@ -107,15 +112,11 @@ BOOST_FIXTURE_TEST_CASE(miniminer_1p1c, TestChain100Setup)
107112
LOCK2(::cs_main, pool.cs);
108113
TestMemPoolEntryHelper entry;
109114

110-
const CAmount low_fee{CENT/2000};
111-
const CAmount normal_fee{CENT/200};
112-
const CAmount high_fee{CENT/10};
113-
114115
// Create a parent tx0 and child tx1 with normal fees:
115116
const auto tx0 = make_tx({COutPoint{m_coinbase_txns[0]->GetHash(), 0}}, /*num_outputs=*/2);
116-
pool.addUnchecked(entry.Fee(normal_fee).FromTx(tx0));
117+
pool.addUnchecked(entry.Fee(med_fee).FromTx(tx0));
117118
const auto tx1 = make_tx({COutPoint{tx0->GetHash(), 0}}, /*num_outputs=*/1);
118-
pool.addUnchecked(entry.Fee(normal_fee).FromTx(tx1));
119+
pool.addUnchecked(entry.Fee(med_fee).FromTx(tx1));
119120

120121
// Create a low-feerate parent tx2 and high-feerate child tx3 (cpfp)
121122
const auto tx2 = make_tx({COutPoint{m_coinbase_txns[1]->GetHash(), 0}}, /*num_outputs=*/2);
@@ -128,9 +129,10 @@ BOOST_FIXTURE_TEST_CASE(miniminer_1p1c, TestChain100Setup)
128129
pool.addUnchecked(entry.Fee(low_fee).FromTx(tx4));
129130
const auto tx5 = make_tx({COutPoint{tx4->GetHash(), 0}}, /*num_outputs=*/1);
130131
pool.addUnchecked(entry.Fee(low_fee).FromTx(tx5));
132+
const CAmount tx5_delta{CENT/100};
131133
// Make tx5's modified fee much higher than its base fee. This should cause it to pass
132134
// the fee-related checks despite being low-feerate.
133-
pool.PrioritiseTransaction(tx5->GetHash(), CENT/100);
135+
pool.PrioritiseTransaction(tx5->GetHash(), tx5_delta);
134136

135137
// Create a high-feerate parent tx6, low-feerate child tx7
136138
const auto tx6 = make_tx({COutPoint{m_coinbase_txns[3]->GetHash(), 0}}, /*num_outputs=*/2);
@@ -342,10 +344,6 @@ BOOST_FIXTURE_TEST_CASE(miniminer_overlap, TestChain100Setup)
342344
LOCK2(::cs_main, pool.cs);
343345
TestMemPoolEntryHelper entry;
344346

345-
const CAmount low_fee{CENT/2000}; // 500 ṩ
346-
const CAmount med_fee{CENT/200}; // 5000 ṩ
347-
const CAmount high_fee{CENT/10}; // 100_000 ṩ
348-
349347
// Create 3 parents of different feerates, and 1 child spending outputs from all 3 parents.
350348
const auto tx0 = make_tx({COutPoint{m_coinbase_txns[0]->GetHash(), 0}}, /*num_outputs=*/2);
351349
pool.addUnchecked(entry.Fee(low_fee).FromTx(tx0));

0 commit comments

Comments
 (0)