Skip to content

Commit

Permalink
f Check we see all txids exactly once
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Nov 8, 2023
1 parent 1824514 commit c7316c3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lightning-transaction-sync/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -507,19 +507,22 @@ 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"),
}

match events[1] {
TestConfirmableEvent::Unconfirmed(t) => {
assert!(t == txid || t == second_txid);
assert!(seen_txids.insert(t));
},
_ => panic!("Unexpected event"),
}
Expand All @@ -532,14 +535,18 @@ fn test_electrum_syncs() {
match events[3] {
TestConfirmableEvent::Confirmed(t, _, _) => {
assert!(t == txid || t == second_txid);
assert!(seen_txids.remove(&t));
},
_ => panic!("Unexpected event"),
}

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);
}

0 comments on commit c7316c3

Please sign in to comment.