Skip to content

Commit

Permalink
fuzz: add package RBF subpackage size assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Jun 11, 2024
1 parent a4efa3a commit 5bb449c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/util/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
wtxid.ToString());
}

if (!atmp_result.m_replaced_transactions.empty() && mempool) {
LOCK(mempool->cs);
// If replacements occurred and it used 2 transactions, this is a package RBF and should result in a cluster of size 2
if (atmp_result.m_wtxids_fee_calculations.has_value() && atmp_result.m_wtxids_fee_calculations.value().size() == 2) {
const auto cluster = mempool->GatherClusters({tx->GetHash()});
if (cluster.size() != 2) return strprintf("tx %s has too many ancestors or descendants for a package rbf", wtxid.ToString());
}
}

// m_vsize and m_base_fees should exist iff the result was VALID or MEMPOOL_ENTRY
const bool mempool_entry{atmp_result.m_result_type == MempoolAcceptResult::ResultType::MEMPOOL_ENTRY};
if (atmp_result.m_base_fees.has_value() != (valid || mempool_entry)) {
Expand Down

0 comments on commit 5bb449c

Please sign in to comment.