fuzz: Improve oracle for existing CCoinControl tests
What changed, and why it matters
This commit only improves a fuzz test for the Bitcoin Core wallet's coin selection helper. It adds extra checks (assertions) inside the test to make sure the coin control object behaves as expected. It does not change any production wallet code, network code, or consensus rules, so it cannot introduce a security vulnerability in the running software.
No security action required. Treat as a normal test-quality improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies src/wallet/test/fuzz/coincontrol.cpp, a fuzzing harness. It replaces several no-op casts with assertions that verify CCoinControl state after Select/UnSelect/UnSelectAll/SetTxOut/SetInputWeight/ListSelected calls. These are test-only oracle improvements; no CCoinControl implementation logic is changed.
Changed components
src/wallet/test/fuzz/coincontrol.cppInspect captured patch +28 / −6
diff --git a/src/wallet/test/fuzz/coincontrol.cpp b/src/wallet/test/fuzz/coincontrol.cpp
index 6774a21d..e46a469f 100644
--- a/src/wallet/test/fuzz/coincontrol.cpp
+++ b/src/wallet/test/fuzz/coincontrol.cpp
@@ -57,26 +57,48 @@ FUZZ_TARGET(coincontrol, .init = initialize_coincontrol)
},
[&] {
(void)coin_control.Select(out_point);
+ assert(coin_control.IsSelected(out_point));
},
[&] {
const CTxOut tx_out{ConsumeMoney(fuzzed_data_provider), ConsumeScript(fuzzed_data_provider)};
- (void)coin_control.Select(out_point).SetTxOut(tx_out);
+ auto& input = coin_control.Select(out_point);
+ const auto set_tx_out{fuzzed_data_provider.ConsumeBool()};
+ if (set_tx_out) {
+ input.SetTxOut(tx_out);
+ }
+ auto has_tx_out{input.HasTxOut()};
+ auto is_external_selected{coin_control.IsExternalSelected(out_point)};
+ if (set_tx_out) {
+ assert(has_tx_out);
+ assert(input.GetTxOut() == tx_out);
+ assert(is_external_selected);
+ } else if (!has_tx_out) {
+ assert(!is_external_selected);
+ }
},
[&] {
- (void)coin_control.UnSelect(out_point);
+ coin_control.UnSelect(out_point);
+ assert(!coin_control.IsSelected(out_point));
},
[&] {
- (void)coin_control.UnSelectAll();
+ coin_control.UnSelectAll();
+ assert(!coin_control.HasSelected());
},
[&] {
- (void)coin_control.ListSelected();
+ const std::vector<COutPoint> selected = coin_control.ListSelected();
+ for (const auto& out : selected) {
+ assert(coin_control.IsSelected(out));
+ }
},
[&] {
int64_t weight{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
- (void)coin_control.SetInputWeight(out_point, weight);
+ coin_control.SetInputWeight(out_point, weight);
+ assert(coin_control.GetInputWeight(out_point) == weight);
},
[&] {
- (void)coin_control.GetInputWeight(out_point);
+ const bool is_selected = coin_control.IsSelected(out_point);
+ assert(!coin_control.GetInputWeight(out_point) || is_selected);
+ assert(!coin_control.GetSequence(out_point) || is_selected);
});
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.