Add test for sighash_single_bug incompatility fix
This commit is contained in:
parent
5d38073afb
commit
7ab2f5be40
|
@ -1545,8 +1545,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sighash_single_bug() {
|
fn sighash_single_bug() {
|
||||||
const SIGHASH_SINGLE: u32 = 3;
|
|
||||||
|
|
||||||
// We need a tx with more inputs than outputs.
|
// We need a tx with more inputs than outputs.
|
||||||
let tx = Transaction {
|
let tx = Transaction {
|
||||||
version: transaction::Version::ONE,
|
version: transaction::Version::ONE,
|
||||||
|
@ -1557,10 +1555,16 @@ mod tests {
|
||||||
let script = ScriptBuf::new();
|
let script = ScriptBuf::new();
|
||||||
let cache = SighashCache::new(&tx);
|
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);
|
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]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue