@@ -463,7 +463,7 @@ fn test_electrum_syncs() {
463463	assert ! ( confirmable. confirmed_txs. lock( ) . unwrap( ) . contains_key( & txid) ) ; 
464464	assert ! ( confirmable. unconfirmed_txs. lock( ) . unwrap( ) . is_empty( ) ) ; 
465465
466- 	// Now take a random  output of the first  transaction and check we'll confirm its spend. 
466+ 	// Now take an arbitrary  output of the second  transaction and check we'll confirm its spend. 
467467	let  tx_res = bitcoind. client . get_transaction ( & second_txid,  None ) . unwrap ( ) ; 
468468	let  block_hash = tx_res. info . blockhash . unwrap ( ) ; 
469469	let  tx = tx_res. transaction ( ) . unwrap ( ) ; 
@@ -507,19 +507,22 @@ fn test_electrum_syncs() {
507507	assert ! ( confirmable. unconfirmed_txs. lock( ) . unwrap( ) . is_empty( ) ) ; 
508508
509509	// Check we got unconfirmed, then reconfirmed in the meantime. 
510+ 	let  mut  seen_txids = HashSet :: new ( ) ; 
510511	let  events = std:: mem:: take ( & mut  * confirmable. events . lock ( ) . unwrap ( ) ) ; 
511512	assert_eq ! ( events. len( ) ,  5 ) ; 
512513
513514	match  events[ 0 ]  { 
514515		TestConfirmableEvent :: Unconfirmed ( t)  => { 
515516			assert ! ( t == txid || t == second_txid) ; 
517+ 			assert ! ( seen_txids. insert( t) ) ; 
516518		} , 
517519		_ => panic ! ( "Unexpected event" ) , 
518520	} 
519521
520522	match  events[ 1 ]  { 
521523		TestConfirmableEvent :: Unconfirmed ( t)  => { 
522524			assert ! ( t == txid || t == second_txid) ; 
525+ 			assert ! ( seen_txids. insert( t) ) ; 
523526		} , 
524527		_ => panic ! ( "Unexpected event" ) , 
525528	} 
@@ -532,14 +535,18 @@ fn test_electrum_syncs() {
532535	match  events[ 3 ]  { 
533536		TestConfirmableEvent :: Confirmed ( t,  _,  _)  => { 
534537			assert ! ( t == txid || t == second_txid) ; 
538+ 			assert ! ( seen_txids. remove( & t) ) ; 
535539		} , 
536540		_ => panic ! ( "Unexpected event" ) , 
537541	} 
538542
539543	match  events[ 4 ]  { 
540544		TestConfirmableEvent :: Confirmed ( t,  _,  _)  => { 
541545			assert ! ( t == txid || t == second_txid) ; 
546+ 			assert ! ( seen_txids. remove( & t) ) ; 
542547		} , 
543548		_ => panic ! ( "Unexpected event" ) , 
544549	} 
550+ 
551+ 	assert_eq ! ( seen_txids. len( ) ,  0 ) ; 
545552} 
0 commit comments