Skip to content

Commit b684d82

Browse files
committed
fuzz: Add more invariant checks for package_rbf
1 parent 2a3ada8 commit b684d82

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/fuzz/rbf.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,16 @@ FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
178178

179179
// If internals report error, wrapper should too
180180
auto err_tuple{ImprovesFeerateDiagram(pool, direct_conflicts, all_conflicts, replacement_fees, replacement_vsize)};
181-
if (!calc_results.has_value()) assert(err_tuple.value().first == DiagramCheckError::UNCALCULABLE);
181+
if (!calc_results.has_value()) {
182+
assert(err_tuple.value().first == DiagramCheckError::UNCALCULABLE);
183+
} else {
184+
// Diagram check succeeded
185+
if (!err_tuple.has_value()) {
186+
// New diagram's final fee should always match or exceed old diagram's
187+
assert(calc_results->first.back().fee <= calc_results->second.back().fee);
188+
} else if (calc_results->first.back().fee > calc_results->second.back().fee) {
189+
// Or it failed, and if old diagram had higher fees, it should be a failure
190+
assert(err_tuple.value().first == DiagramCheckError::FAILURE);
191+
}
192+
}
182193
}

0 commit comments

Comments
 (0)