Add failing test for `SerializedSignature` fix
What changed, and why it matters
This commit only adds a new unit test for a bug fix that was already applied in the previous commit. It does not change any production code itself. The test verifies that a Taproot signature can be serialized back to the same hex string it was parsed from. Because the actual fix happened earlier, this commit alone does not introduce, fix, or worsen any security issue.
No action required for this commit alone. Review the preceding commit that actually changed `SerializedSignature` serialization logic to assess any security relevance.
Security signals we found
Commit is purely additive test code
No production code changes
References a fix in a previous commit but does not contain it
Evidence from the diff
The diff refactors an existing test array into a module-level constant SIG_STRINGS and adds a new test serialized_signature_hex that checks Signature::parse(...).serialize().to_string() round-trips correctly. The commit message explicitly states the test is meant to fail if ordered before the previous commit and pass after it, confirming the functional change was in the prior commit. No cryptographic, parsing, or serialization logic is modified here.
Changed components
crypto/src/taproot.rs testsInspect captured patch +20 / −10
diff --git a/crypto/src/taproot.rs b/crypto/src/taproot.rs
index 6bf7deb3..23174cbe 100644
--- a/crypto/src/taproot.rs
+++ b/crypto/src/taproot.rs
@@ -535,18 +535,19 @@ mod tests {
}
}
+ const SIG_STRINGS: &[&str] = &[
+ // default sighash type
+ "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab",
+ // various sighash types
+ "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab01",
+ "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab02",
+ "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab03",
+ "7777777777777777abababababababababababababababababababababababababababababababababababababababababababababababababababababababab81",
+ ];
+
#[test]
fn signature_hex_roundtrip() {
- let sig_strings = [
- // default sighash type
- "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab",
- // various sighash types
- "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab01",
- "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab02",
- "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab03",
- "7777777777777777abababababababababababababababababababababababababababababababababababababababababababababababababababababababab81",
- ];
- for want in sig_strings {
+ for &want in SIG_STRINGS {
let sig = want.parse::<Signature>().unwrap();
let got = sig.to_string();
assert_eq!(got, want);
@@ -562,4 +563,13 @@ mod tests {
ParseSignatureError::Decode(SigFromSliceError::SighashType(InvalidSighashTypeError(0))),
));
}
+
+ #[test]
+ fn serialized_signature_hex() {
+ for &want in SIG_STRINGS {
+ let sig = want.parse::<Signature>().unwrap();
+ let got = sig.serialize().to_string();
+ assert_eq!(got, want);
+ }
+ }
}
Why this scored 11/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.