@@ -102,9 +102,11 @@ pub struct TestFeeEstimator {
102102}
103103impl TestFeeEstimator {
104104 pub fn new ( sat_per_kw : u32 ) -> Self {
105+ let sat_per_kw = Mutex :: new ( sat_per_kw) ;
106+ let target_override = Mutex :: new ( new_hash_map ( ) ) ;
105107 Self {
106- sat_per_kw : Mutex :: new ( sat_per_kw ) ,
107- target_override : Mutex :: new ( new_hash_map ( ) ) ,
108+ sat_per_kw,
109+ target_override,
108110 }
109111 }
110112}
@@ -135,11 +137,13 @@ impl<'a> TestRouter<'a> {
135137 scorer : & ' a RwLock < TestScorer > ,
136138 ) -> Self {
137139 let entropy_source = Arc :: new ( RandomBytes :: new ( [ 42 ; 32 ] ) ) ;
140+ let next_routes = Mutex :: new ( VecDeque :: new ( ) ) ;
141+ let next_blinded_payment_paths = Mutex :: new ( Vec :: new ( ) ) ;
138142 Self {
139143 router : DefaultRouter :: new ( network_graph. clone ( ) , logger, entropy_source, scorer, Default :: default ( ) ) ,
140144 network_graph,
141- next_routes : Mutex :: new ( VecDeque :: new ( ) ) ,
142- next_blinded_payment_paths : Mutex :: new ( Vec :: new ( ) ) ,
145+ next_routes,
146+ next_blinded_payment_paths,
143147 scorer,
144148 }
145149 }
@@ -350,14 +354,19 @@ pub struct TestChainMonitor<'a> {
350354}
351355impl < ' a > TestChainMonitor < ' a > {
352356 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 {
357+ let added_monitors = Mutex :: new ( Vec :: new ( ) ) ;
358+ let monitor_updates = Mutex :: new ( new_hash_map ( ) ) ;
359+ let latest_monitor_update_id = Mutex :: new ( new_hash_map ( ) ) ;
360+ let expect_channel_force_closed = Mutex :: new ( None ) ;
361+ let expect_monitor_round_trip_fail = Mutex :: new ( None ) ;
353362 Self {
354- added_monitors : Mutex :: new ( Vec :: new ( ) ) ,
355- monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
356- latest_monitor_update_id : Mutex :: new ( new_hash_map ( ) ) ,
363+ added_monitors,
364+ monitor_updates,
365+ latest_monitor_update_id,
357366 chain_monitor : chainmonitor:: ChainMonitor :: new ( chain_source, broadcaster, logger, fee_estimator, persister) ,
358367 keys_manager,
359- expect_channel_force_closed : Mutex :: new ( None ) ,
360- expect_monitor_round_trip_fail : Mutex :: new ( None ) ,
368+ expect_channel_force_closed,
369+ expect_monitor_round_trip_fail,
361370 }
362371 }
363372
@@ -449,10 +458,12 @@ pub(crate) struct WatchtowerPersister {
449458impl WatchtowerPersister {
450459 #[ cfg( test) ]
451460 pub ( crate ) fn new ( destination_script : ScriptBuf ) -> Self {
461+ let unsigned_justice_tx_data = Mutex :: new ( new_hash_map ( ) ) ;
462+ let watchtower_state = Mutex :: new ( new_hash_map ( ) ) ;
452463 WatchtowerPersister {
453464 persister : TestPersister :: new ( ) ,
454- unsigned_justice_tx_data : Mutex :: new ( new_hash_map ( ) ) ,
455- watchtower_state : Mutex :: new ( new_hash_map ( ) ) ,
465+ unsigned_justice_tx_data,
466+ watchtower_state,
456467 destination_script,
457468 }
458469 }
@@ -551,10 +562,13 @@ pub struct TestPersister {
551562}
552563impl TestPersister {
553564 pub fn new ( ) -> Self {
565+ let update_rets = Mutex :: new ( VecDeque :: new ( ) ) ;
566+ let offchain_monitor_updates = Mutex :: new ( new_hash_map ( ) ) ;
567+ let chain_sync_monitor_persistences = Mutex :: new ( VecDeque :: new ( ) ) ;
554568 Self {
555- update_rets : Mutex :: new ( VecDeque :: new ( ) ) ,
556- offchain_monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
557- chain_sync_monitor_persistences : Mutex :: new ( VecDeque :: new ( ) )
569+ update_rets,
570+ offchain_monitor_updates,
571+ chain_sync_monitor_persistences
558572 }
559573 }
560574
@@ -693,14 +707,17 @@ pub struct TestBroadcaster {
693707
694708impl TestBroadcaster {
695709 pub fn new ( network : Network ) -> Self {
710+ let txn_broadcasted = Mutex :: new ( Vec :: new ( ) ) ;
711+ let blocks = Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block( network) , 0 ) ] ) ) ;
696712 Self {
697- txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) ,
698- blocks : Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block ( network ) , 0 ) ] ) ) ,
713+ txn_broadcasted,
714+ blocks,
699715 }
700716 }
701717
702718 pub fn with_blocks ( blocks : Arc < Mutex < Vec < ( Block , u32 ) > > > ) -> Self {
703- Self { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) , blocks }
719+ let txn_broadcasted = Mutex :: new ( Vec :: new ( ) ) ;
720+ Self { txn_broadcasted, blocks }
704721 }
705722
706723 pub fn txn_broadcast ( & self ) -> Vec < Transaction > {
@@ -748,10 +765,13 @@ impl TestChannelMessageHandler {
748765
749766impl TestChannelMessageHandler {
750767 pub fn new ( chain_hash : ChainHash ) -> Self {
768+ let pending_events = Mutex :: new ( Vec :: new ( ) ) ;
769+ let expected_recv_msgs = Mutex :: new ( None ) ;
770+ let connected_peers = Mutex :: new ( new_hash_set ( ) ) ;
751771 TestChannelMessageHandler {
752- pending_events : Mutex :: new ( Vec :: new ( ) ) ,
753- expected_recv_msgs : Mutex :: new ( None ) ,
754- connected_peers : Mutex :: new ( new_hash_set ( ) ) ,
772+ pending_events,
773+ expected_recv_msgs,
774+ connected_peers,
755775 chain_hash,
756776 }
757777 }
@@ -990,10 +1010,11 @@ pub struct TestRoutingMessageHandler {
9901010
9911011impl TestRoutingMessageHandler {
9921012 pub fn new ( ) -> Self {
1013+ let pending_events = Mutex :: new ( vec ! [ ] ) ;
9931014 TestRoutingMessageHandler {
9941015 chan_upds_recvd : AtomicUsize :: new ( 0 ) ,
9951016 chan_anns_recvd : AtomicUsize :: new ( 0 ) ,
996- pending_events : Mutex :: new ( vec ! [ ] ) ,
1017+ pending_events,
9971018 request_full_sync : AtomicBool :: new ( false ) ,
9981019 announcement_available_for_sync : AtomicBool :: new ( false ) ,
9991020 }
@@ -1108,10 +1129,12 @@ impl TestLogger {
11081129 Self :: with_id ( "" . to_owned ( ) )
11091130 }
11101131 pub fn with_id ( id : String ) -> TestLogger {
1132+ let lines = Mutex :: new ( new_hash_map ( ) ) ;
1133+ let context = Mutex :: new ( new_hash_map ( ) ) ;
11111134 TestLogger {
11121135 id,
1113- lines : Mutex :: new ( new_hash_map ( ) ) ,
1114- context : Mutex :: new ( new_hash_map ( ) ) ,
1136+ lines,
1137+ context,
11151138 }
11161139 }
11171140 pub fn assert_log ( & self , module : & str , line : String , count : usize ) {
@@ -1324,13 +1347,17 @@ impl SignerProvider for TestKeysInterface {
13241347impl TestKeysInterface {
13251348 pub fn new ( seed : & [ u8 ; 32 ] , network : Network ) -> Self {
13261349 let now = Duration :: from_secs ( genesis_block ( network) . header . time as u64 ) ;
1350+ let override_random_bytes = Mutex :: new ( None ) ;
1351+ let enforcement_states = Mutex :: new ( new_hash_map ( ) ) ;
1352+ let expectations = Mutex :: new ( None ) ;
1353+ let unavailable_signers_ops = Mutex :: new ( new_hash_map ( ) ) ;
13271354 Self {
13281355 backing : sign:: PhantomKeysManager :: new ( seed, now. as_secs ( ) , now. subsec_nanos ( ) , seed) ,
1329- override_random_bytes : Mutex :: new ( None ) ,
1356+ override_random_bytes,
13301357 disable_revocation_policy_check : false ,
1331- enforcement_states : Mutex :: new ( new_hash_map ( ) ) ,
1332- expectations : Mutex :: new ( None ) ,
1333- unavailable_signers_ops : Mutex :: new ( new_hash_map ( ) ) ,
1358+ enforcement_states,
1359+ expectations,
1360+ unavailable_signers_ops,
13341361 }
13351362 }
13361363
@@ -1396,12 +1423,15 @@ pub struct TestChainSource {
13961423impl TestChainSource {
13971424 pub fn new ( network : Network ) -> Self {
13981425 let script_pubkey = Builder :: new ( ) . push_opcode ( opcodes:: OP_TRUE ) . into_script ( ) ;
1426+ let utxo_ret = Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ;
1427+ let watched_txn = Mutex :: new ( new_hash_set ( ) ) ;
1428+ let watched_outputs = Mutex :: new ( new_hash_set ( ) ) ;
13991429 Self {
14001430 chain_hash : ChainHash :: using_genesis_block ( network) ,
1401- utxo_ret : Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ,
1431+ utxo_ret,
14021432 get_utxo_call_count : AtomicUsize :: new ( 0 ) ,
1403- watched_txn : Mutex :: new ( new_hash_set ( ) ) ,
1404- watched_outputs : Mutex :: new ( new_hash_set ( ) ) ,
1433+ watched_txn,
1434+ watched_outputs,
14051435 }
14061436 }
14071437 pub fn remove_watched_txn_and_outputs ( & self , outpoint : OutPoint , script_pubkey : ScriptBuf ) {
0 commit comments