Skip to content

Commit 84be66b

Browse files
committed
test(electrum): test populate_with_txids does not panic
1 parent b33c0a5 commit 84be66b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crates/electrum/src/bdk_electrum_client.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,30 @@ fn chain_update(
552552
}
553553
Ok(tip)
554554
}
555+
556+
#[cfg(test)]
557+
mod test {
558+
use crate::{bdk_electrum_client::TxUpdate, BdkElectrumClient};
559+
use bdk_testenv::{utils::new_tx, TestEnv};
560+
561+
#[cfg(feature = "default")]
562+
#[test]
563+
fn test_populate_with_txids_without_output() {
564+
let env = TestEnv::new().unwrap();
565+
let electrum_client =
566+
electrum_client::Client::new(env.electrsd.electrum_url.as_str()).unwrap();
567+
let client = BdkElectrumClient::new(electrum_client);
568+
569+
// Setup transaction with no outputs.
570+
let tx = new_tx(0);
571+
572+
// Populate tx_cache with `tx` to make it fetchable.
573+
client.populate_tx_cache(vec![tx.clone()]);
574+
575+
// Test that populate_with_txids does not panic or process a tx with no output.
576+
let mut tx_update = TxUpdate::default();
577+
let _ = client.populate_with_txids(&mut tx_update, vec![tx.compute_txid()]);
578+
579+
assert_eq!(tx_update.txs, Vec::new());
580+
}
581+
}

0 commit comments

Comments
 (0)