fuzz: Add more invariant checks for package_rbf

This commit is contained in:
Greg Sanders 2024-03-25 12:01:32 -04:00
parent 2a3ada8b21
commit b684d82d7e
1 changed files with 12 additions and 1 deletions

View File

@ -178,5 +178,16 @@ FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
// If internals report error, wrapper should too
auto err_tuple{ImprovesFeerateDiagram(pool, direct_conflicts, all_conflicts, replacement_fees, replacement_vsize)};
if (!calc_results.has_value()) assert(err_tuple.value().first == DiagramCheckError::UNCALCULABLE);
if (!calc_results.has_value()) {
assert(err_tuple.value().first == DiagramCheckError::UNCALCULABLE);
} else {
// Diagram check succeeded
if (!err_tuple.has_value()) {
// New diagram's final fee should always match or exceed old diagram's
assert(calc_results->first.back().fee <= calc_results->second.back().fee);
} else if (calc_results->first.back().fee > calc_results->second.back().fee) {
// Or it failed, and if old diagram had higher fees, it should be a failure
assert(err_tuple.value().first == DiagramCheckError::FAILURE);
}
}
}