Skip to content

Commit 74cafd3

Browse files
committed
f Check we see all txids exactly once
1 parent afbb875 commit 74cafd3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning-transaction-sync/tests/integration_tests.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ fn test_electrum_syncs() {
461461
assert!(confirmable.confirmed_txs.lock().unwrap().contains_key(&txid));
462462
assert!(confirmable.unconfirmed_txs.lock().unwrap().is_empty());
463463

464-
// Now take a random output of the first transaction and check we'll confirm its spend.
464+
// Now take an arbitrary output of the second transaction and check we'll confirm its spend.
465465
let tx_res = bitcoind.client.get_transaction(&second_txid, None).unwrap();
466466
let block_hash = tx_res.info.blockhash.unwrap();
467467
let tx = tx_res.transaction().unwrap();
@@ -505,19 +505,22 @@ fn test_electrum_syncs() {
505505
assert!(confirmable.unconfirmed_txs.lock().unwrap().is_empty());
506506

507507
// Check we got unconfirmed, then reconfirmed in the meantime.
508+
let mut seen_txids = HashSet::new();
508509
let events = std::mem::take(&mut *confirmable.events.lock().unwrap());
509510
assert_eq!(events.len(), 5);
510511

511512
match events[0] {
512513
TestConfirmableEvent::Unconfirmed(t) => {
513514
assert!(t == txid || t == second_txid);
515+
assert!(seen_txids.insert(t));
514516
},
515517
_ => panic!("Unexpected event"),
516518
}
517519

518520
match events[1] {
519521
TestConfirmableEvent::Unconfirmed(t) => {
520522
assert!(t == txid || t == second_txid);
523+
assert!(seen_txids.insert(t));
521524
},
522525
_ => panic!("Unexpected event"),
523526
}
@@ -530,14 +533,18 @@ fn test_electrum_syncs() {
530533
match events[3] {
531534
TestConfirmableEvent::Confirmed(t, _, _) => {
532535
assert!(t == txid || t == second_txid);
536+
assert!(seen_txids.remove(&t));
533537
},
534538
_ => panic!("Unexpected event"),
535539
}
536540

537541
match events[4] {
538542
TestConfirmableEvent::Confirmed(t, _, _) => {
539543
assert!(t == txid || t == second_txid);
544+
assert!(seen_txids.remove(&t));
540545
},
541546
_ => panic!("Unexpected event"),
542547
}
548+
549+
assert_eq!(seen_txids.len(), 0);
543550
}

0 commit comments

Comments
 (0)