Skip to content

Commit

Permalink
Merge pull request #1453 from zcash/fix-tx-view-bug
Browse files Browse the repository at this point in the history
`zcash_client_sqlite`: Fix bug in `utxos_to_txos` migration
  • Loading branch information
nuttycom authored Jul 23, 2024
2 parents a5e467f + bbb73b0 commit 104c0c2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
3 changes: 1 addition & 2 deletions zcash_client_sqlite/src/testing.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::ffi::OsStr;
use std::fmt;
use std::num::NonZeroU32;
use std::{collections::BTreeMap, convert::Infallible};

#[cfg(feature = "unstable")]
use std::fs::File;
use std::{ffi::OsStr, fs::File};

use group::ff::Field;
use incrementalmerkletree::{Marking, Position, Retention};
Expand Down
29 changes: 29 additions & 0 deletions zcash_client_sqlite/src/testing/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ pub(crate) fn send_multi_step_proposed_transfer<T: ShieldedPoolTester>() {
legacy::keys::{NonHardenedChildIndex, TransparentKeyScope},
transaction::builder::{BuildConfig, Builder},
};
use zcash_protocol::value::ZatBalance;

use crate::wallet::{sapling::tests::test_prover, GAP_LIMIT};

Expand Down Expand Up @@ -452,6 +453,34 @@ pub(crate) fn send_multi_step_proposed_transfer<T: ShieldedPoolTester>() {
(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)
};

Expand Down
2 changes: 1 addition & 1 deletion zcash_client_sqlite/src/wallet/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ notes AS (
ON ros.pool = ro.pool
AND ros.received_output_id = ro.id_within_pool_table
JOIN transactions
ON transactions.id_tx = ro.transaction_id
ON transactions.id_tx = ros.transaction_id
),
-- Obtain a count of the notes that the wallet created in each transaction,
-- not counting change notes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl RusqliteMigration for Migration {
ON ros.pool = ro.pool
AND ros.received_output_id = ro.id_within_pool_table
JOIN transactions
ON transactions.id_tx = ro.transaction_id
ON transactions.id_tx = ros.transaction_id
),
-- Obtain a count of the notes that the wallet created in each transaction,
-- not counting change notes.
Expand Down

0 comments on commit 104c0c2

Please sign in to comment.