What changed, and why it matters
This commit only improves the wording of error messages shown when tests fail. It does not change any production code, behavior, or security logic.
Recommended action
No security action needed. This is a routine test-quality improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test-only panic messages in bitcoin/src/crypto/key.rs and bitcoin/src/psbt/mod.rs. Empty or vague panic strings are replaced with descriptive messages that include the actual unexpected error variant. No runtime code paths are affected.
Changed components
bitcoin/src/crypto/key.rs (tests)bitcoin/src/psbt/mod.rs (tests)Inspect captured patch +6 / −6
diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs
index dec67a29..abc24946 100644
--- a/bitcoin/src/crypto/key.rs
+++ b/bitcoin/src/crypto/key.rs
@@ -1825,7 +1825,7 @@ mod tests {
assert_eq!(err.invalid_char(), b'g');
assert_eq!(err.pos(), 129);
} else {
- panic!("Expected Invalid char error");
+ panic!("expected ParsePublicKeyError::InvalidChar");
}
let s = "032e58afe51f9ed8ad3cc7897f634d881fdbe49a81564629ded8156bebd2ffd1ag";
@@ -1836,7 +1836,7 @@ mod tests {
assert_eq!(err.invalid_char(), b'g');
assert_eq!(err.pos(), 65);
} else {
- panic!("Expected Invalid char error");
+ panic!("expected ParsePublicKeyError::InvalidChar");
}
}
diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs
index 91e13a72..ed3cddec 100644
--- a/bitcoin/src/psbt/mod.rs
+++ b/bitcoin/src/psbt/mod.rs
@@ -1447,7 +1447,7 @@ mod tests {
.extract_tx_with_fee_rate_limit(FeeRate::from_sat_per_vb(1))
.map_err(|e| match e {
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
- _ => panic!(""),
+ other => panic!("expected AbsurdFeeRate error, got {other:?}"),
})
.unwrap_err();
@@ -1459,14 +1459,14 @@ mod tests {
assert_eq!(
psbt.clone().extract_tx().map_err(|e| match e {
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
- _ => panic!(""),
+ other => panic!("expected AbsurdFeeRate error, got {other:?}"),
}),
Err(error_fee_rate)
);
assert_eq!(
psbt.clone().extract_tx_fee_rate_limit().map_err(|e| match e {
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
- _ => panic!(""),
+ other => panic!("expected AbsurdFeeRate error, got {other:?}"),
}),
Err(error_fee_rate)
);
@@ -1480,7 +1480,7 @@ mod tests {
assert_eq!(
psbt_with_amounts(2076001, 1000).extract_tx().map_err(|e| match e {
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
- _ => panic!(""),
+ other => panic!("expected AbsurdFeeRate error, got {other:?}"),
}),
Err(FeeRate::from_sat_per_kwu(6250003)) // 6250000 is 25k sat/vbyte
);
Risk score
Our methodology →Why this scored 15/100
Human-validated context
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
No validated notes yet.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.