primitives: fix tests that created txs with no outputs
What changed, and why it matters
This commit only updates two internal unit tests so they create transactions that have at least one output. The change is a test-only follow-up after the library started rejecting transactions with no outputs. There is no change to production code, no security fix, and no vulnerability being patched.
No action required; this is a benign test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes #[ignore] annotations from block_decode and decode_zero_inputs and adds a dummy TxOut (1 sat to an empty script_pubkey) so the test transactions pass the new validation rule that rejects zero-output transactions. The diff is entirely within #[cfg(test)] modules in primitives/src/block.rs and primitives/src/transaction.rs. No consensus, serialization, or validation logic is modified.
Changed components
primitives/src/block.rs (tests)primitives/src/transaction.rs (tests)Inspect captured patch +6 / −5
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index 5190efad..052ac10b 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -1284,7 +1284,6 @@ mod tests {
}
#[test]
- #[ignore] // bad test; will be fixed in next commit
#[cfg(feature = "alloc")]
fn block_decode() {
// Make a simple block, encode then decode. Verify equivalence.
@@ -1320,7 +1319,10 @@ mod tests {
sequence: crate::sequence::Sequence::MAX,
witness: crate::witness::Witness::new(),
}],
- outputs: Vec::new(),
+ outputs: vec![crate::transaction::TxOut {
+ amount: units::Amount::ONE_SAT,
+ script_pubkey: crate::script::ScriptPubKeyBuf::new(),
+ }],
}];
let original_block = Block::new_unchecked(header, transactions);
diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs
index 07dc18b6..efbd3b58 100644
--- a/primitives/src/transaction.rs
+++ b/primitives/src/transaction.rs
@@ -2397,16 +2397,15 @@ mod tests {
}
#[test]
- #[ignore] // bad test; will be fixed in next commit
#[cfg(feature = "alloc")]
fn decode_zero_inputs() {
- // Test empty transaction with no inputs or outputs.
+ // Test transaction with no inputs (but with one output to satisfy validation).
let block: u32 = 741_521;
let original_tx = Transaction {
version: Version::ONE,
lock_time: absolute::LockTime::from_height(block).expect("valid height"),
inputs: vec![],
- outputs: vec![],
+ outputs: vec![TxOut { amount: Amount::ONE_SAT, script_pubkey: ScriptPubKeyBuf::new() }],
};
let encoded = encoding::encode_to_vec(&original_tx);
Why this scored 15/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.