Skip to content

Commit 7ab2f5b

Browse files
committed
Add test for sighash_single_bug incompatility fix
1 parent 5d38073 commit 7ab2f5b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bitcoin/src/crypto/sighash.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,6 @@ mod tests {
15451545

15461546
#[test]
15471547
fn sighash_single_bug() {
1548-
const SIGHASH_SINGLE: u32 = 3;
1549-
15501548
// We need a tx with more inputs than outputs.
15511549
let tx = Transaction {
15521550
version: transaction::Version::ONE,
@@ -1557,10 +1555,16 @@ mod tests {
15571555
let script = ScriptBuf::new();
15581556
let cache = SighashCache::new(&tx);
15591557

1560-
let got = cache.legacy_signature_hash(1, &script, SIGHASH_SINGLE).expect("sighash");
1558+
let sighash_single = 3;
1559+
let got = cache.legacy_signature_hash(1, &script, sighash_single).expect("sighash");
15611560
let want = LegacySighash::from_byte_array(UINT256_ONE);
1561+
assert_eq!(got, want);
15621562

1563-
assert_eq!(got, want)
1563+
// https://github.com/rust-bitcoin/rust-bitcoin/issues/4112
1564+
let sighash_single = 131;
1565+
let got = cache.legacy_signature_hash(1, &script, sighash_single).expect("sighash");
1566+
let want = LegacySighash::from_byte_array(UINT256_ONE);
1567+
assert_eq!(got, want);
15641568
}
15651569

15661570
#[test]

0 commit comments

Comments
 (0)