Skip to content

Commit

Permalink
test(electrum): test populate_with_txids does not panic
Browse files Browse the repository at this point in the history
  • Loading branch information
LagginTimes committed Dec 8, 2024
1 parent cdf7f32 commit da155b2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,27 @@ mod test {
use bdk_testenv::{utils::new_tx, TestEnv};
use std::sync::Arc;

#[cfg(feature = "default")]
#[test]
fn test_populate_with_txids_without_output() {
let env = TestEnv::new().unwrap();
let electrum_client =
electrum_client::Client::new(env.electrsd.electrum_url.as_str()).unwrap();
let client = BdkElectrumClient::new(electrum_client);

// Setup transaction with no outputs.
let tx = new_tx(0);

// Populate tx_cache with `tx` to make it fetchable.
client.populate_tx_cache(vec![tx.clone()]);

// Test that populate_with_txids does not panic or process a tx with no output.
let mut tx_update = TxUpdate::default();
let _ = client.populate_with_txids(&mut tx_update, vec![tx.compute_txid()]);

assert_eq!(tx_update.txs, Vec::new());
}

#[cfg(feature = "default")]
#[test]
fn test_fetch_prev_txout_with_coinbase() {
Expand Down

0 comments on commit da155b2

Please sign in to comment.