diff --git a/lightning-transaction-sync/tests/integration_tests.rs b/lightning-transaction-sync/tests/integration_tests.rs index e0db8630e3a..1e2e4f35ea8 100644 --- a/lightning-transaction-sync/tests/integration_tests.rs +++ b/lightning-transaction-sync/tests/integration_tests.rs @@ -463,7 +463,7 @@ fn test_electrum_syncs() { assert!(confirmable.confirmed_txs.lock().unwrap().contains_key(&txid)); assert!(confirmable.unconfirmed_txs.lock().unwrap().is_empty()); - // Now take a random output of the first transaction and check we'll confirm its spend. + // Now take an arbitrary output of the second transaction and check we'll confirm its spend. let tx_res = bitcoind.client.get_transaction(&second_txid, None).unwrap(); let block_hash = tx_res.info.blockhash.unwrap(); let tx = tx_res.transaction().unwrap(); @@ -507,12 +507,14 @@ fn test_electrum_syncs() { assert!(confirmable.unconfirmed_txs.lock().unwrap().is_empty()); // Check we got unconfirmed, then reconfirmed in the meantime. + let mut seen_txids = HashSet::new(); let events = std::mem::take(&mut *confirmable.events.lock().unwrap()); assert_eq!(events.len(), 5); match events[0] { TestConfirmableEvent::Unconfirmed(t) => { assert!(t == txid || t == second_txid); + assert!(seen_txids.insert(t)); }, _ => panic!("Unexpected event"), } @@ -520,6 +522,7 @@ fn test_electrum_syncs() { match events[1] { TestConfirmableEvent::Unconfirmed(t) => { assert!(t == txid || t == second_txid); + assert!(seen_txids.insert(t)); }, _ => panic!("Unexpected event"), } @@ -532,6 +535,7 @@ fn test_electrum_syncs() { match events[3] { TestConfirmableEvent::Confirmed(t, _, _) => { assert!(t == txid || t == second_txid); + assert!(seen_txids.remove(&t)); }, _ => panic!("Unexpected event"), } @@ -539,7 +543,10 @@ fn test_electrum_syncs() { match events[4] { TestConfirmableEvent::Confirmed(t, _, _) => { assert!(t == txid || t == second_txid); + assert!(seen_txids.remove(&t)); }, _ => panic!("Unexpected event"), } + + assert_eq!(seen_txids.len(), 0); }