Skip to content

Commit

Permalink
Merge bitcoindevkit#1785: test(wallet): small cleanups to test_wallet…
Browse files Browse the repository at this point in the history
…_transactions_relevant

6346536 test(wallet): small cleanups to test_wallet_transactions_relevant (Steve Myers)

Pull request description:

  ### Description

  This cleans up the `test_wallet_transactions_relevant` test based on suggestions that didn't make it into bitcoindevkit#1779.

  ### Notes to the reviewers

  Also included a small use cleanup in wallet/mod.

  ### Changelog notice

  None.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  luisschwab:
    ACK 6346536
  ValuedMammal:
    ACK 6346536

Tree-SHA512: f9604518d2b9bb5614385a053efb03d53311f359626d45270f3648209ab0e31ba966995f842fff1c35f0c83848c61f0976f91524a3f457c6cd85e3f0929f4a77
  • Loading branch information
ValuedMammal committed Dec 23, 2024
2 parents 03a08bb + 6346536 commit a208144
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
3 changes: 1 addition & 2 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use alloc::{
sync::Arc,
vec::Vec,
};
use chain::Indexer;
use core::{cmp::Ordering, fmt, mem, ops::Deref};

use bdk_chain::{
Expand All @@ -32,7 +31,7 @@ use bdk_chain::{
},
tx_graph::{CalculateFeeError, CanonicalTx, TxGraph, TxUpdate},
BlockId, ChainPosition, ConfirmationBlockTime, DescriptorExt, FullTxOut, Indexed,
IndexedTxGraph, Merge,
IndexedTxGraph, Indexer, Merge,
};
use bitcoin::{
absolute,
Expand Down
17 changes: 4 additions & 13 deletions crates/wallet/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;

use anyhow::Context;
use assert_matches::assert_matches;
use bdk_chain::{BlockId, ChainPosition, ConfirmationBlockTime, TxUpdate};
use bdk_chain::{BlockId, ChainPosition, ConfirmationBlockTime};
use bdk_wallet::coin_selection::{self, LargestFirstCoinSelection};
use bdk_wallet::descriptor::{calc_checksum, DescriptorError, IntoWalletDescriptor};
use bdk_wallet::error::CreateTxError;
Expand Down Expand Up @@ -4254,22 +4254,13 @@ fn test_wallet_transactions_relevant() {
// add not relevant transaction to test wallet
let (other_external_desc, other_internal_desc) = get_test_tr_single_sig_xprv_and_change_desc();
let (other_wallet, other_txid) = get_funded_wallet(other_internal_desc, other_external_desc);
let other_tx_node = other_wallet.get_tx(other_txid).unwrap().tx_node;
let other_tx_confirmationblocktime = other_tx_node.anchors.iter().last().unwrap();
let other_tx_update = TxUpdate {
txs: vec![other_tx_node.tx],
txouts: Default::default(),
anchors: [(*other_tx_confirmationblocktime, other_txid)].into(),
seen_ats: [(other_txid, other_tx_confirmationblocktime.confirmation_time)].into(),
};
let test_wallet_update = Update {
last_active_indices: Default::default(),
tx_update: other_tx_update,
chain: None,
tx_update: other_wallet.tx_graph().clone().into(),
..Default::default()
};
test_wallet.apply_update(test_wallet_update).unwrap();

// verify transaction from other wallet was added but is not it relevant transactions list.
// verify transaction from other wallet was added but is not in relevant transactions list.
let relevant_tx_count_after = test_wallet.transactions().count();
let full_tx_count_after = test_wallet.tx_graph().full_txs().count();
let canonical_tx_count_after = test_wallet
Expand Down

0 comments on commit a208144

Please sign in to comment.