Add test for sighash_single_bug incompatility fix

This commit is contained in:
Liu-Cheng Xu 2025-02-25 07:38:36 +08:00
parent 5d38073afb
commit 7ab2f5be40
1 changed files with 8 additions and 4 deletions

View File

@ -1545,8 +1545,6 @@ mod tests {
#[test]
fn sighash_single_bug() {
const SIGHASH_SINGLE: u32 = 3;
// We need a tx with more inputs than outputs.
let tx = Transaction {
version: transaction::Version::ONE,
@ -1557,10 +1555,16 @@ mod tests {
let script = ScriptBuf::new();
let cache = SighashCache::new(&tx);
let got = cache.legacy_signature_hash(1, &script, SIGHASH_SINGLE).expect("sighash");
let sighash_single = 3;
let got = cache.legacy_signature_hash(1, &script, sighash_single).expect("sighash");
let want = LegacySighash::from_byte_array(UINT256_ONE);
assert_eq!(got, want);
assert_eq!(got, want)
// https://github.com/rust-bitcoin/rust-bitcoin/issues/4112
let sighash_single = 131;
let got = cache.legacy_signature_hash(1, &script, sighash_single).expect("sighash");
let want = LegacySighash::from_byte_array(UINT256_ONE);
assert_eq!(got, want);
}
#[test]