What changed, and why it matters
This commit only adds a new unit test that checks whether an error message is non-empty and, when the standard library is available, whether the error has an underlying cause. It does not change any production code, fix a bug, or alter behavior. There is no security relevance.
No action required; this is a test-only addition with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds imports for alloc::string::ToString and std::error::Error plus a test decoder_error_display in primitives/src/script/owned.rs. The test constructs a ScriptBuf decoder, feeds it a single byte, calls end(), and asserts the resulting error’s display string is non-empty and (with std) that source() returns Some. No library logic is modified.
Changed components
primitives/src/script/owned.rsInspect captured patch +18 / −0
diff --git a/primitives/src/script/owned.rs b/primitives/src/script/owned.rs
index 207e1c1a..fb8d6219 100644
--- a/primitives/src/script/owned.rs
+++ b/primitives/src/script/owned.rs
@@ -220,6 +220,10 @@ mod tests {
#[cfg(feature = "alloc")]
use alloc::vec;
+ #[cfg(feature = "alloc")]
+ use alloc::string::ToString;
+ #[cfg(feature = "std")]
+ use std::error::Error as _;
use super::*;
@@ -332,4 +336,18 @@ mod tests {
decoder.push_bytes(&mut push).unwrap();
assert_eq!(decoder.read_limit(), 31);
}
+
+ #[test]
+ #[cfg(feature = "alloc")]
+ fn decoder_error_display() {
+ let bytes = vec![0x01_u8];
+ let mut push = bytes.as_slice();
+ let mut decoder = <ScriptBuf as Decodable>::Decoder::default();
+ decoder.push_bytes(&mut push).unwrap();
+
+ let err = decoder.end().unwrap_err();
+ assert!(!err.to_string().is_empty());
+ #[cfg(feature = "std")]
+ assert!(err.source().is_some());
+ }
}
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.