What changed, and why it matters
This commit only changes test code. It updates two existing tests that check error handling for oversized Bitcoin scripts, making the assertions more robust by verifying the error is non-empty and has no underlying cause. There is no change to production code and no security fix or vulnerability introduced.
No security action needed; this is a routine test-coverage improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies primitives/src/script/tests.rs, specifically the redeem_script_size_error and witness_script_size_error unit tests. It replaces string-content assertions (checking that the formatted error contains the invalid size number) with checks that the error’s Display output is non-empty and, under the std feature, that Error::source() returns None. This is a test-quality improvement with no functional code changes.
Changed components
primitives/src/script/tests.rsInspect captured patch +12 / −4
diff --git a/primitives/src/script/tests.rs b/primitives/src/script/tests.rs
index e0fb2002..2fe6495b 100644
--- a/primitives/src/script/tests.rs
+++ b/primitives/src/script/tests.rs
@@ -355,26 +355,34 @@ fn cow_script_to_box_script() {
#[test]
fn redeem_script_size_error() {
+ #[cfg(feature = "std")]
+ use std::error::Error as _;
+
let script = RedeemScriptBuf::from(vec![0x51; 521]);
let result = ScriptHash::try_from(script);
let err = result.unwrap_err();
assert_eq!(err.invalid_size(), 521);
- let err_msg = format!("{}", err);
- assert!(err_msg.contains("521"));
+ assert!(!err.to_string().is_empty());
+ #[cfg(feature = "std")]
+ assert!(err.source().is_none());
}
#[test]
fn witness_script_size_error() {
+ #[cfg(feature = "std")]
+ use std::error::Error as _;
+
let script = WitnessScriptBuf::from(vec![0x51; 10_001]);
let result = WScriptHash::try_from(script);
let err = result.unwrap_err();
assert_eq!(err.invalid_size(), 10_001);
- let err_msg = format!("{}", err);
- assert!(err_msg.contains("10001"));
+ assert!(!err.to_string().is_empty());
+ #[cfg(feature = "std")]
+ assert!(err.source().is_none());
}
#[test]
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.