Skip to content

Commit

Permalink
Fix confirmations on transparent balance and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pacu committed Oct 23, 2024
1 parent deb00b7 commit a0ca649
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions zcash_client_backend/src/data_api/testing/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ where
st.wallet().get_transparent_balances(account_id, height_2),
Ok(h) if h.get(taddr) == Some(&value)
);
// TODO: Find our why this does not work.

// let unshielded_balance = st.wallet().get_wallet_summary(0)
// .unwrap()
// .unwrap()
// .account_balances
// .get(&account_id)
// .unwrap()
// .unshielded_balance;

// let mut expected_balance = Balance::ZERO;

// expected_balance.add_pending_change_value(value).unwrap();

// assert_eq!(unshielded_balance, expected_balance);

}

pub fn transparent_balance_across_shielding<DSF>(dsf: DSF, cache: impl TestCache)
Expand Down
6 changes: 3 additions & 3 deletions zcash_client_sqlite/src/wallet/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ pub(crate) fn add_transparent_account_balances(
-- the transaction that created the output is mined and with enough confirmations
WHERE (
t.mined_height < :mempool_height -- tx is mined
AND :mempool_height - t.mined_height >= :min_confirmations -- has at least min_confirmations
AND t.mined_height <= (t.mined_height - :min_confirmations) -- has at least min_confirmations
)
-- and the received txo is unspent
AND u.id NOT IN (
Expand Down Expand Up @@ -433,8 +433,8 @@ pub(crate) fn add_transparent_account_balances(
ON t.id_tx = u.transaction_id
-- the transaction that created the output is mined with not enough confirmations or is definitely unexpired
WHERE (
(t.mined_height < :mempool_height
AND (:mempool_height - t.mined_height) < :min_confirmations) -- tx is mined but not confirmed
t.mined_height < :mempool_height
AND t.mined_height > (t.mined_height - :min_confirmations) -- tx is mined but not confirmed
OR t.expiry_height = 0 -- tx will not expire
OR t.expiry_height >= :mempool_height
)
Expand Down

0 comments on commit a0ca649

Please sign in to comment.