@@ -103,9 +103,11 @@ pub struct TestFeeEstimator {
103103}
104104impl TestFeeEstimator {
105105 pub fn new ( sat_per_kw : u32 ) -> Self {
106+ let sat_per_kw = Mutex :: new ( sat_per_kw) ;
107+ let target_override = Mutex :: new ( new_hash_map ( ) ) ;
106108 Self {
107- sat_per_kw : Mutex :: new ( sat_per_kw ) ,
108- target_override : Mutex :: new ( new_hash_map ( ) ) ,
109+ sat_per_kw,
110+ target_override,
109111 }
110112 }
111113}
@@ -136,11 +138,13 @@ impl<'a> TestRouter<'a> {
136138 scorer : & ' a RwLock < TestScorer > ,
137139 ) -> Self {
138140 let entropy_source = Arc :: new ( RandomBytes :: new ( [ 42 ; 32 ] ) ) ;
141+ let next_routes = Mutex :: new ( VecDeque :: new ( ) ) ;
142+ let next_blinded_payment_paths = Mutex :: new ( Vec :: new ( ) ) ;
139143 Self {
140144 router : DefaultRouter :: new ( network_graph. clone ( ) , logger, entropy_source, scorer, Default :: default ( ) ) ,
141145 network_graph,
142- next_routes : Mutex :: new ( VecDeque :: new ( ) ) ,
143- next_blinded_payment_paths : Mutex :: new ( Vec :: new ( ) ) ,
146+ next_routes,
147+ next_blinded_payment_paths,
144148 scorer,
145149 }
146150 }
@@ -377,14 +381,19 @@ pub struct TestChainMonitor<'a> {
377381}
378382impl < ' a > TestChainMonitor < ' a > {
379383 pub fn new ( chain_source : Option < & ' a TestChainSource > , broadcaster : & ' a dyn chaininterface:: BroadcasterInterface , logger : & ' a TestLogger , fee_estimator : & ' a TestFeeEstimator , persister : & ' a dyn chainmonitor:: Persist < TestChannelSigner > , keys_manager : & ' a TestKeysInterface ) -> Self {
384+ let added_monitors = Mutex :: new ( Vec :: new ( ) ) ;
385+ let monitor_updates = Mutex :: new ( new_hash_map ( ) ) ;
386+ let latest_monitor_update_id = Mutex :: new ( new_hash_map ( ) ) ;
387+ let expect_channel_force_closed = Mutex :: new ( None ) ;
388+ let expect_monitor_round_trip_fail = Mutex :: new ( None ) ;
380389 Self {
381- added_monitors : Mutex :: new ( Vec :: new ( ) ) ,
382- monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
383- latest_monitor_update_id : Mutex :: new ( new_hash_map ( ) ) ,
390+ added_monitors,
391+ monitor_updates,
392+ latest_monitor_update_id,
384393 chain_monitor : chainmonitor:: ChainMonitor :: new ( chain_source, broadcaster, logger, fee_estimator, persister) ,
385394 keys_manager,
386- expect_channel_force_closed : Mutex :: new ( None ) ,
387- expect_monitor_round_trip_fail : Mutex :: new ( None ) ,
395+ expect_channel_force_closed,
396+ expect_monitor_round_trip_fail,
388397 }
389398 }
390399
@@ -476,10 +485,12 @@ pub(crate) struct WatchtowerPersister {
476485impl WatchtowerPersister {
477486 #[ cfg( test) ]
478487 pub ( crate ) fn new ( destination_script : ScriptBuf ) -> Self {
488+ let unsigned_justice_tx_data = Mutex :: new ( new_hash_map ( ) ) ;
489+ let watchtower_state = Mutex :: new ( new_hash_map ( ) ) ;
479490 WatchtowerPersister {
480491 persister : TestPersister :: new ( ) ,
481- unsigned_justice_tx_data : Mutex :: new ( new_hash_map ( ) ) ,
482- watchtower_state : Mutex :: new ( new_hash_map ( ) ) ,
492+ unsigned_justice_tx_data,
493+ watchtower_state,
483494 destination_script,
484495 }
485496 }
@@ -578,10 +589,13 @@ pub struct TestPersister {
578589}
579590impl TestPersister {
580591 pub fn new ( ) -> Self {
592+ let update_rets = Mutex :: new ( VecDeque :: new ( ) ) ;
593+ let offchain_monitor_updates = Mutex :: new ( new_hash_map ( ) ) ;
594+ let chain_sync_monitor_persistences = Mutex :: new ( VecDeque :: new ( ) ) ;
581595 Self {
582- update_rets : Mutex :: new ( VecDeque :: new ( ) ) ,
583- offchain_monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
584- chain_sync_monitor_persistences : Mutex :: new ( VecDeque :: new ( ) )
596+ update_rets,
597+ offchain_monitor_updates,
598+ chain_sync_monitor_persistences
585599 }
586600 }
587601
@@ -720,14 +734,17 @@ pub struct TestBroadcaster {
720734
721735impl TestBroadcaster {
722736 pub fn new ( network : Network ) -> Self {
737+ let txn_broadcasted = Mutex :: new ( Vec :: new ( ) ) ;
738+ let blocks = Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block( network) , 0 ) ] ) ) ;
723739 Self {
724- txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) ,
725- blocks : Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block ( network ) , 0 ) ] ) ) ,
740+ txn_broadcasted,
741+ blocks,
726742 }
727743 }
728744
729745 pub fn with_blocks ( blocks : Arc < Mutex < Vec < ( Block , u32 ) > > > ) -> Self {
730- Self { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) , blocks }
746+ let txn_broadcasted = Mutex :: new ( Vec :: new ( ) ) ;
747+ Self { txn_broadcasted, blocks }
731748 }
732749
733750 pub fn txn_broadcast ( & self ) -> Vec < Transaction > {
@@ -775,10 +792,13 @@ impl TestChannelMessageHandler {
775792
776793impl TestChannelMessageHandler {
777794 pub fn new ( chain_hash : ChainHash ) -> Self {
795+ let pending_events = Mutex :: new ( Vec :: new ( ) ) ;
796+ let expected_recv_msgs = Mutex :: new ( None ) ;
797+ let connected_peers = Mutex :: new ( new_hash_set ( ) ) ;
778798 TestChannelMessageHandler {
779- pending_events : Mutex :: new ( Vec :: new ( ) ) ,
780- expected_recv_msgs : Mutex :: new ( None ) ,
781- connected_peers : Mutex :: new ( new_hash_set ( ) ) ,
799+ pending_events,
800+ expected_recv_msgs,
801+ connected_peers,
782802 chain_hash,
783803 }
784804 }
@@ -1016,10 +1036,11 @@ pub struct TestRoutingMessageHandler {
10161036
10171037impl TestRoutingMessageHandler {
10181038 pub fn new ( ) -> Self {
1039+ let pending_events = Mutex :: new ( vec ! [ ] ) ;
10191040 TestRoutingMessageHandler {
10201041 chan_upds_recvd : AtomicUsize :: new ( 0 ) ,
10211042 chan_anns_recvd : AtomicUsize :: new ( 0 ) ,
1022- pending_events : Mutex :: new ( vec ! [ ] ) ,
1043+ pending_events,
10231044 request_full_sync : AtomicBool :: new ( false ) ,
10241045 }
10251046 }
@@ -1129,10 +1150,12 @@ impl TestLogger {
11291150 Self :: with_id ( "" . to_owned ( ) )
11301151 }
11311152 pub fn with_id ( id : String ) -> TestLogger {
1153+ let lines = Mutex :: new ( new_hash_map ( ) ) ;
1154+ let context = Mutex :: new ( new_hash_map ( ) ) ;
11321155 TestLogger {
11331156 id,
1134- lines : Mutex :: new ( new_hash_map ( ) ) ,
1135- context : Mutex :: new ( new_hash_map ( ) ) ,
1157+ lines,
1158+ context,
11361159 }
11371160 }
11381161 pub fn assert_log ( & self , module : & str , line : String , count : usize ) {
@@ -1357,13 +1380,17 @@ impl SignerProvider for TestKeysInterface {
13571380impl TestKeysInterface {
13581381 pub fn new ( seed : & [ u8 ; 32 ] , network : Network ) -> Self {
13591382 let now = Duration :: from_secs ( genesis_block ( network) . header . time as u64 ) ;
1383+ let override_random_bytes = Mutex :: new ( None ) ;
1384+ let enforcement_states = Mutex :: new ( new_hash_map ( ) ) ;
1385+ let expectations = Mutex :: new ( None ) ;
1386+ let unavailable_signers_ops = Mutex :: new ( new_hash_map ( ) ) ;
13601387 Self {
13611388 backing : sign:: PhantomKeysManager :: new ( seed, now. as_secs ( ) , now. subsec_nanos ( ) , seed) ,
1362- override_random_bytes : Mutex :: new ( None ) ,
1389+ override_random_bytes,
13631390 disable_revocation_policy_check : false ,
1364- enforcement_states : Mutex :: new ( new_hash_map ( ) ) ,
1365- expectations : Mutex :: new ( None ) ,
1366- unavailable_signers_ops : Mutex :: new ( new_hash_map ( ) ) ,
1391+ enforcement_states,
1392+ expectations,
1393+ unavailable_signers_ops,
13671394 }
13681395 }
13691396
@@ -1429,12 +1456,15 @@ pub struct TestChainSource {
14291456impl TestChainSource {
14301457 pub fn new ( network : Network ) -> Self {
14311458 let script_pubkey = Builder :: new ( ) . push_opcode ( opcodes:: OP_TRUE ) . into_script ( ) ;
1459+ let utxo_ret = Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ;
1460+ let watched_txn = Mutex :: new ( new_hash_set ( ) ) ;
1461+ let watched_outputs = Mutex :: new ( new_hash_set ( ) ) ;
14321462 Self {
14331463 chain_hash : ChainHash :: using_genesis_block ( network) ,
1434- utxo_ret : Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ,
1464+ utxo_ret,
14351465 get_utxo_call_count : AtomicUsize :: new ( 0 ) ,
1436- watched_txn : Mutex :: new ( new_hash_set ( ) ) ,
1437- watched_outputs : Mutex :: new ( new_hash_set ( ) ) ,
1466+ watched_txn,
1467+ watched_outputs,
14381468 }
14391469 }
14401470 pub fn remove_watched_txn_and_outputs ( & self , outpoint : OutPoint , script_pubkey : ScriptBuf ) {
0 commit comments