From e29622e972374e98852753f2cfc2763f80b20adf Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 23 Jul 2024 16:45:12 +0000 Subject: [PATCH] zcash_client_sqlite: Check that ZIP 320 spend creates expected history --- zcash_client_sqlite/src/testing/pool.rs | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/zcash_client_sqlite/src/testing/pool.rs b/zcash_client_sqlite/src/testing/pool.rs index 5e64a06eb..76d172749 100644 --- a/zcash_client_sqlite/src/testing/pool.rs +++ b/zcash_client_sqlite/src/testing/pool.rs @@ -313,6 +313,7 @@ pub(crate) fn send_multi_step_proposed_transfer() { legacy::keys::{NonHardenedChildIndex, TransparentKeyScope}, transaction::builder::{BuildConfig, Builder}, }; + use zcash_protocol::value::ZatBalance; use crate::wallet::{sapling::tests::test_prover, GAP_LIMIT}; @@ -452,6 +453,34 @@ pub(crate) fn send_multi_step_proposed_transfer() { (sent_v, sent_to_addr, None, None) if sent_v == u64::try_from(transfer_amount).unwrap() && sent_to_addr == Some(tex_addr.encode(&st.wallet().params))); + // Check that the transaction history matches what we expect. + let tx_history = st.get_tx_history().unwrap(); + + let tx_0 = tx_history + .iter() + .find(|tx| tx.txid() == *txids.first()) + .unwrap(); + let tx_1 = tx_history + .iter() + .find(|tx| tx.txid() == *txids.last()) + .unwrap(); + + assert_eq!(tx_0.account_id(), &account_id); + assert!(!tx_0.expired_unmined()); + assert_eq!(tx_0.has_change(), expected_step0_change.is_positive()); + assert_eq!( + tx_0.account_value_delta(), + -ZatBalance::from(expected_step0_fee), + ); + + assert_eq!(tx_1.account_id(), &account_id); + assert!(!tx_1.expired_unmined()); + assert!(!tx_1.has_change()); + assert_eq!( + tx_1.account_value_delta(), + -ZatBalance::from(expected_ephemeral), + ); + (ephemeral_addr.unwrap(), txids) };