Stop using `TxOut::NULL` in tests

We want to get rid of this constant, so we replace it in tests with 0
amount, empty script. Notably, the tests were already using it as a
dummy value - the exact amount was irrelevant, so this change doesn't
break anything.
This commit is contained in:
Martin Habovstiak 2025-01-29 22:30:13 +01:00
parent 313406d6ab
commit a9ffb1571c
2 changed files with 6 additions and 4 deletions

View File

@ -1530,6 +1530,8 @@ mod tests {
extern crate serde_json; extern crate serde_json;
const DUMMY_TXOUT: TxOut = TxOut { value: Amount::MIN, script_pubkey: ScriptBuf::new() };
#[test] #[test]
fn sighash_single_bug() { fn sighash_single_bug() {
const SIGHASH_SINGLE: u32 = 3; const SIGHASH_SINGLE: u32 = 3;
@ -1539,7 +1541,7 @@ mod tests {
version: transaction::Version::ONE, version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO, lock_time: absolute::LockTime::ZERO,
input: vec![TxIn::EMPTY_COINBASE, TxIn::EMPTY_COINBASE], input: vec![TxIn::EMPTY_COINBASE, TxIn::EMPTY_COINBASE],
output: vec![TxOut::NULL], output: vec![DUMMY_TXOUT],
}; };
let script = ScriptBuf::new(); let script = ScriptBuf::new();
let cache = SighashCache::new(&tx); let cache = SighashCache::new(&tx);
@ -1740,13 +1742,13 @@ mod tests {
c.taproot_signature_hash(0, &empty_prevouts, None, None, TapSighashType::All), c.taproot_signature_hash(0, &empty_prevouts, None, None, TapSighashType::All),
Err(TaprootError::PrevoutsSize(PrevoutsSizeError)) Err(TaprootError::PrevoutsSize(PrevoutsSizeError))
); );
let two = [TxOut::NULL, TxOut::NULL]; let two = [DUMMY_TXOUT, DUMMY_TXOUT];
let too_many_prevouts = Prevouts::All(&two); let too_many_prevouts = Prevouts::All(&two);
assert_eq!( assert_eq!(
c.taproot_signature_hash(0, &too_many_prevouts, None, None, TapSighashType::All), c.taproot_signature_hash(0, &too_many_prevouts, None, None, TapSighashType::All),
Err(TaprootError::PrevoutsSize(PrevoutsSizeError)) Err(TaprootError::PrevoutsSize(PrevoutsSizeError))
); );
let tx_out = TxOut::NULL; let tx_out = DUMMY_TXOUT;
let prevout = Prevouts::One(1, &tx_out); let prevout = Prevouts::One(1, &tx_out);
assert_eq!( assert_eq!(
c.taproot_signature_hash(0, &prevout, None, None, TapSighashType::All), c.taproot_signature_hash(0, &prevout, None, None, TapSighashType::All),

View File

@ -2279,7 +2279,7 @@ mod tests {
version: transaction::Version::TWO, version: transaction::Version::TWO,
lock_time: absolute::LockTime::ZERO, lock_time: absolute::LockTime::ZERO,
input: vec![TxIn::EMPTY_COINBASE, TxIn::EMPTY_COINBASE], input: vec![TxIn::EMPTY_COINBASE, TxIn::EMPTY_COINBASE],
output: vec![TxOut::NULL], output: vec![TxOut { value: Amount::from_sat(0), script_pubkey: ScriptBuf::new() }],
}; };
let mut psbt = Psbt::from_unsigned_tx(unsigned_tx).unwrap(); let mut psbt = Psbt::from_unsigned_tx(unsigned_tx).unwrap();