Fix `v5_tx_with_no_outputs_fails_validation` test

This commit is contained in:
Marek 2024-12-20 13:33:17 +01:00
parent b83e826a84
commit 61085712f6
1 changed files with 22 additions and 15 deletions

View File

@ -903,22 +903,29 @@ async fn state_error_converted_correctly() {
#[test]
fn v5_transaction_with_no_outputs_fails_validation() {
let transaction = v5_transactions(zebra_test::vectors::MAINNET_BLOCKS.iter())
.rev()
.find(|transaction| {
transaction.outputs().is_empty()
&& transaction.sapling_outputs().next().is_none()
&& transaction.orchard_actions().next().is_none()
&& transaction.joinsplit_count() == 0
&& (!transaction.inputs().is_empty()
|| transaction.sapling_spends_per_anchor().next().is_some())
})
.expect("At least one fake v5 transaction with no outputs in the test vectors");
assert_eq!(
check::has_inputs_and_outputs(&transaction),
Err(TransactionError::NoOutputs)
let (input, _, _) = mock_transparent_transfer(
Height(1),
true,
0,
Amount::try_from(1).expect("valid value"),
);
for net in Network::iter() {
let transaction = Transaction::V5 {
inputs: vec![input.clone()],
outputs: vec![],
lock_time: LockTime::Height(block::Height(0)),
expiry_height: NetworkUpgrade::Nu5.activation_height(&net).expect("height"),
sapling_shielded_data: None,
orchard_shielded_data: None,
network_upgrade: NetworkUpgrade::Nu5,
};
assert_eq!(
check::has_inputs_and_outputs(&transaction),
Err(TransactionError::NoOutputs)
);
}
}
#[test]