@@ -103,9 +103,11 @@ pub struct TestFeeEstimator {
103
103
}
104
104
impl TestFeeEstimator {
105
105
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 ( ) ) ;
106
108
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,
109
111
}
110
112
}
111
113
}
@@ -136,11 +138,13 @@ impl<'a> TestRouter<'a> {
136
138
scorer : & ' a RwLock < TestScorer > ,
137
139
) -> Self {
138
140
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 ( ) ) ;
139
143
Self {
140
144
router : DefaultRouter :: new ( network_graph. clone ( ) , logger, entropy_source, scorer, Default :: default ( ) ) ,
141
145
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,
144
148
scorer,
145
149
}
146
150
}
@@ -351,14 +355,19 @@ pub struct TestChainMonitor<'a> {
351
355
}
352
356
impl < ' a > TestChainMonitor < ' a > {
353
357
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 {
358
+ let added_monitors = Mutex :: new ( Vec :: new ( ) ) ;
359
+ let monitor_updates = Mutex :: new ( new_hash_map ( ) ) ;
360
+ let latest_monitor_update_id = Mutex :: new ( new_hash_map ( ) ) ;
361
+ let expect_channel_force_closed = Mutex :: new ( None ) ;
362
+ let expect_monitor_round_trip_fail = Mutex :: new ( None ) ;
354
363
Self {
355
- added_monitors : Mutex :: new ( Vec :: new ( ) ) ,
356
- monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
357
- latest_monitor_update_id : Mutex :: new ( new_hash_map ( ) ) ,
364
+ added_monitors,
365
+ monitor_updates,
366
+ latest_monitor_update_id,
358
367
chain_monitor : chainmonitor:: ChainMonitor :: new ( chain_source, broadcaster, logger, fee_estimator, persister) ,
359
368
keys_manager,
360
- expect_channel_force_closed : Mutex :: new ( None ) ,
361
- expect_monitor_round_trip_fail : Mutex :: new ( None ) ,
369
+ expect_channel_force_closed,
370
+ expect_monitor_round_trip_fail,
362
371
}
363
372
}
364
373
@@ -450,10 +459,12 @@ pub(crate) struct WatchtowerPersister {
450
459
impl WatchtowerPersister {
451
460
#[ cfg( test) ]
452
461
pub ( crate ) fn new ( destination_script : ScriptBuf ) -> Self {
462
+ let unsigned_justice_tx_data = Mutex :: new ( new_hash_map ( ) ) ;
463
+ let watchtower_state = Mutex :: new ( new_hash_map ( ) ) ;
453
464
WatchtowerPersister {
454
465
persister : TestPersister :: new ( ) ,
455
- unsigned_justice_tx_data : Mutex :: new ( new_hash_map ( ) ) ,
456
- watchtower_state : Mutex :: new ( new_hash_map ( ) ) ,
466
+ unsigned_justice_tx_data,
467
+ watchtower_state,
457
468
destination_script,
458
469
}
459
470
}
@@ -552,10 +563,13 @@ pub struct TestPersister {
552
563
}
553
564
impl TestPersister {
554
565
pub fn new ( ) -> Self {
566
+ let update_rets = Mutex :: new ( VecDeque :: new ( ) ) ;
567
+ let offchain_monitor_updates = Mutex :: new ( new_hash_map ( ) ) ;
568
+ let chain_sync_monitor_persistences = Mutex :: new ( VecDeque :: new ( ) ) ;
555
569
Self {
556
- update_rets : Mutex :: new ( VecDeque :: new ( ) ) ,
557
- offchain_monitor_updates : Mutex :: new ( new_hash_map ( ) ) ,
558
- chain_sync_monitor_persistences : Mutex :: new ( VecDeque :: new ( ) )
570
+ update_rets,
571
+ offchain_monitor_updates,
572
+ chain_sync_monitor_persistences
559
573
}
560
574
}
561
575
@@ -694,14 +708,17 @@ pub struct TestBroadcaster {
694
708
695
709
impl TestBroadcaster {
696
710
pub fn new ( network : Network ) -> Self {
711
+ let txn_broadcasted = Mutex :: new ( Vec :: new ( ) ) ;
712
+ let blocks = Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block( network) , 0 ) ] ) ) ;
697
713
Self {
698
- txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) ,
699
- blocks : Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block ( network ) , 0 ) ] ) ) ,
714
+ txn_broadcasted,
715
+ blocks,
700
716
}
701
717
}
702
718
703
719
pub fn with_blocks ( blocks : Arc < Mutex < Vec < ( Block , u32 ) > > > ) -> Self {
704
- Self { txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) , blocks }
720
+ let txn_broadcasted = Mutex :: new ( Vec :: new ( ) ) ;
721
+ Self { txn_broadcasted, blocks }
705
722
}
706
723
707
724
pub fn txn_broadcast ( & self ) -> Vec < Transaction > {
@@ -749,10 +766,13 @@ impl TestChannelMessageHandler {
749
766
750
767
impl TestChannelMessageHandler {
751
768
pub fn new ( chain_hash : ChainHash ) -> Self {
769
+ let pending_events = Mutex :: new ( Vec :: new ( ) ) ;
770
+ let expected_recv_msgs = Mutex :: new ( None ) ;
771
+ let connected_peers = Mutex :: new ( new_hash_set ( ) ) ;
752
772
TestChannelMessageHandler {
753
- pending_events : Mutex :: new ( Vec :: new ( ) ) ,
754
- expected_recv_msgs : Mutex :: new ( None ) ,
755
- connected_peers : Mutex :: new ( new_hash_set ( ) ) ,
773
+ pending_events,
774
+ expected_recv_msgs,
775
+ connected_peers,
756
776
chain_hash,
757
777
}
758
778
}
@@ -991,10 +1011,11 @@ pub struct TestRoutingMessageHandler {
991
1011
992
1012
impl TestRoutingMessageHandler {
993
1013
pub fn new ( ) -> Self {
1014
+ let pending_events = Mutex :: new ( vec ! [ ] ) ;
994
1015
TestRoutingMessageHandler {
995
1016
chan_upds_recvd : AtomicUsize :: new ( 0 ) ,
996
1017
chan_anns_recvd : AtomicUsize :: new ( 0 ) ,
997
- pending_events : Mutex :: new ( vec ! [ ] ) ,
1018
+ pending_events,
998
1019
request_full_sync : AtomicBool :: new ( false ) ,
999
1020
announcement_available_for_sync : AtomicBool :: new ( false ) ,
1000
1021
}
@@ -1109,10 +1130,12 @@ impl TestLogger {
1109
1130
Self :: with_id ( "" . to_owned ( ) )
1110
1131
}
1111
1132
pub fn with_id ( id : String ) -> TestLogger {
1133
+ let lines = Mutex :: new ( new_hash_map ( ) ) ;
1134
+ let context = Mutex :: new ( new_hash_map ( ) ) ;
1112
1135
TestLogger {
1113
1136
id,
1114
- lines : Mutex :: new ( new_hash_map ( ) ) ,
1115
- context : Mutex :: new ( new_hash_map ( ) ) ,
1137
+ lines,
1138
+ context,
1116
1139
}
1117
1140
}
1118
1141
pub fn assert_log ( & self , module : & str , line : String , count : usize ) {
@@ -1330,14 +1353,19 @@ impl SignerProvider for TestKeysInterface {
1330
1353
impl TestKeysInterface {
1331
1354
pub fn new ( seed : & [ u8 ; 32 ] , network : Network ) -> Self {
1332
1355
let now = Duration :: from_secs ( genesis_block ( network) . header . time as u64 ) ;
1356
+ let override_random_bytes = Mutex :: new ( None ) ;
1357
+ let enforcement_states = Mutex :: new ( new_hash_map ( ) ) ;
1358
+ let expectations = Mutex :: new ( None ) ;
1359
+ let unavailable_signers_ops = Mutex :: new ( new_hash_map ( ) ) ;
1360
+ let next_signer_disabled_ops = Mutex :: new ( new_hash_set ( ) ) ;
1333
1361
Self {
1334
1362
backing : sign:: PhantomKeysManager :: new ( seed, now. as_secs ( ) , now. subsec_nanos ( ) , seed) ,
1335
- override_random_bytes : Mutex :: new ( None ) ,
1363
+ override_random_bytes,
1336
1364
disable_revocation_policy_check : false ,
1337
- enforcement_states : Mutex :: new ( new_hash_map ( ) ) ,
1338
- expectations : Mutex :: new ( None ) ,
1339
- unavailable_signers_ops : Mutex :: new ( new_hash_map ( ) ) ,
1340
- next_signer_disabled_ops : Mutex :: new ( new_hash_set ( ) ) ,
1365
+ enforcement_states,
1366
+ expectations,
1367
+ unavailable_signers_ops,
1368
+ next_signer_disabled_ops,
1341
1369
}
1342
1370
}
1343
1371
@@ -1403,12 +1431,15 @@ pub struct TestChainSource {
1403
1431
impl TestChainSource {
1404
1432
pub fn new ( network : Network ) -> Self {
1405
1433
let script_pubkey = Builder :: new ( ) . push_opcode ( opcodes:: OP_TRUE ) . into_script ( ) ;
1434
+ let utxo_ret = Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ;
1435
+ let watched_txn = Mutex :: new ( new_hash_set ( ) ) ;
1436
+ let watched_outputs = Mutex :: new ( new_hash_set ( ) ) ;
1406
1437
Self {
1407
1438
chain_hash : ChainHash :: using_genesis_block ( network) ,
1408
- utxo_ret : Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ,
1439
+ utxo_ret,
1409
1440
get_utxo_call_count : AtomicUsize :: new ( 0 ) ,
1410
- watched_txn : Mutex :: new ( new_hash_set ( ) ) ,
1411
- watched_outputs : Mutex :: new ( new_hash_set ( ) ) ,
1441
+ watched_txn,
1442
+ watched_outputs,
1412
1443
}
1413
1444
}
1414
1445
pub fn remove_watched_txn_and_outputs ( & self , outpoint : OutPoint , script_pubkey : ScriptBuf ) {
0 commit comments