mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
fuzz: Fix tx_pool target to properly fuzz immature outpoints
This commit is contained in:
parent
fa2b95f861
commit
fac921f23f
@ -16,7 +16,8 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const TestingSetup* g_setup;
|
const TestingSetup* g_setup;
|
||||||
std::vector<COutPoint> g_outpoints_coinbase_init;
|
std::vector<COutPoint> g_outpoints_coinbase_init_mature;
|
||||||
|
std::vector<COutPoint> g_outpoints_coinbase_init_immature;
|
||||||
|
|
||||||
struct MockedTxPool : public CTxMemPool {
|
struct MockedTxPool : public CTxMemPool {
|
||||||
void RollingFeeUpdate()
|
void RollingFeeUpdate()
|
||||||
@ -34,7 +35,10 @@ void initialize_tx_pool()
|
|||||||
for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
|
for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
|
||||||
CTxIn in = MineBlock(g_setup->m_node, P2WSH_OP_TRUE);
|
CTxIn in = MineBlock(g_setup->m_node, P2WSH_OP_TRUE);
|
||||||
// Remember the txids to avoid expensive disk acess later on
|
// Remember the txids to avoid expensive disk acess later on
|
||||||
g_outpoints_coinbase_init.push_back(in.prevout);
|
auto& outpoints = i < COINBASE_MATURITY ?
|
||||||
|
g_outpoints_coinbase_init_mature :
|
||||||
|
g_outpoints_coinbase_init_immature;
|
||||||
|
outpoints.push_back(in.prevout);
|
||||||
}
|
}
|
||||||
SyncWithValidationInterfaceQueue();
|
SyncWithValidationInterfaceQueue();
|
||||||
}
|
}
|
||||||
@ -86,9 +90,8 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
|
|||||||
std::set<COutPoint> outpoints_rbf;
|
std::set<COutPoint> outpoints_rbf;
|
||||||
// All outpoints counting toward the total supply (subset of outpoints_rbf)
|
// All outpoints counting toward the total supply (subset of outpoints_rbf)
|
||||||
std::set<COutPoint> outpoints_supply;
|
std::set<COutPoint> outpoints_supply;
|
||||||
for (const auto& outpoint : g_outpoints_coinbase_init) {
|
for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
|
||||||
Assert(outpoints_supply.insert(outpoint).second);
|
Assert(outpoints_supply.insert(outpoint).second);
|
||||||
if (outpoints_supply.size() >= COINBASE_MATURITY) break;
|
|
||||||
}
|
}
|
||||||
outpoints_rbf = outpoints_supply;
|
outpoints_rbf = outpoints_supply;
|
||||||
|
|
||||||
@ -253,13 +256,12 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
|
|||||||
const auto& node = g_setup->m_node;
|
const auto& node = g_setup->m_node;
|
||||||
|
|
||||||
std::vector<uint256> txids;
|
std::vector<uint256> txids;
|
||||||
for (const auto& outpoint : g_outpoints_coinbase_init) {
|
for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
|
||||||
txids.push_back(outpoint.hash);
|
txids.push_back(outpoint.hash);
|
||||||
if (txids.size() >= COINBASE_MATURITY) break;
|
|
||||||
}
|
}
|
||||||
for (int i{0}; i <= 3; ++i) {
|
for (int i{0}; i <= 3; ++i) {
|
||||||
// Add some immature and non-existent outpoints
|
// Add some immature and non-existent outpoints
|
||||||
txids.push_back(g_outpoints_coinbase_init.at(i).hash);
|
txids.push_back(g_outpoints_coinbase_init_immature.at(i).hash);
|
||||||
txids.push_back(ConsumeUInt256(fuzzed_data_provider));
|
txids.push_back(ConsumeUInt256(fuzzed_data_provider));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user