16
16
namespace {
17
17
18
18
const TestingSetup* g_setup;
19
- std::vector<COutPoint> g_outpoints_coinbase_init;
19
+ std::vector<COutPoint> g_outpoints_coinbase_init_mature;
20
+ std::vector<COutPoint> g_outpoints_coinbase_init_immature;
20
21
21
22
struct MockedTxPool : public CTxMemPool {
22
23
void RollingFeeUpdate ()
@@ -34,7 +35,10 @@ void initialize_tx_pool()
34
35
for (int i = 0 ; i < 2 * COINBASE_MATURITY; ++i) {
35
36
CTxIn in = MineBlock (g_setup->m_node , P2WSH_OP_TRUE);
36
37
// Remember the txids to avoid expensive disk acess later on
37
- g_outpoints_coinbase_init.push_back (in.prevout );
38
+ auto & outpoints = i < COINBASE_MATURITY ?
39
+ g_outpoints_coinbase_init_mature :
40
+ g_outpoints_coinbase_init_immature;
41
+ outpoints.push_back (in.prevout );
38
42
}
39
43
SyncWithValidationInterfaceQueue ();
40
44
}
@@ -86,24 +90,22 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
86
90
std::set<COutPoint> outpoints_rbf;
87
91
// All outpoints counting toward the total supply (subset of outpoints_rbf)
88
92
std::set<COutPoint> outpoints_supply;
89
- for (const auto & outpoint : g_outpoints_coinbase_init ) {
93
+ for (const auto & outpoint : g_outpoints_coinbase_init_mature ) {
90
94
Assert (outpoints_supply.insert (outpoint).second );
91
- if (outpoints_supply.size () >= COINBASE_MATURITY) break ;
92
95
}
93
96
outpoints_rbf = outpoints_supply;
94
97
95
98
// The sum of the values of all spendable outpoints
96
99
constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN};
97
100
98
101
CTxMemPool tx_pool_{/* estimator */ nullptr , /* check_ratio */ 1 };
99
- MockedTxPool& tx_pool = *( MockedTxPool*) &tx_pool_;
102
+ MockedTxPool& tx_pool = *static_cast < MockedTxPool*>( &tx_pool_) ;
100
103
101
104
// Helper to query an amount
102
105
const CCoinsViewMemPool amount_view{WITH_LOCK (::cs_main, return &chainstate.CoinsTip ()), tx_pool};
103
106
const auto GetAmount = [&](const COutPoint& outpoint) {
104
107
Coin c;
105
- amount_view.GetCoin (outpoint, c);
106
- Assert (!c.IsSpent ());
108
+ Assert (amount_view.GetCoin (outpoint, c));
107
109
return c.out .nValue ;
108
110
};
109
111
@@ -254,13 +256,12 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
254
256
const auto & node = g_setup->m_node ;
255
257
256
258
std::vector<uint256> txids;
257
- for (const auto & outpoint : g_outpoints_coinbase_init ) {
259
+ for (const auto & outpoint : g_outpoints_coinbase_init_mature ) {
258
260
txids.push_back (outpoint.hash );
259
- if (txids.size () >= COINBASE_MATURITY) break ;
260
261
}
261
262
for (int i{0 }; i <= 3 ; ++i) {
262
263
// Add some immature and non-existent outpoints
263
- txids.push_back (g_outpoints_coinbase_init .at (i).hash );
264
+ txids.push_back (g_outpoints_coinbase_init_immature .at (i).hash );
264
265
txids.push_back (ConsumeUInt256 (fuzzed_data_provider));
265
266
}
266
267
0 commit comments