@@ -102,9 +102,11 @@ pub struct TestFeeEstimator {
102
102
}
103
103
impl TestFeeEstimator {
104
104
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 ( ) ) ;
105
107
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,
108
110
}
109
111
}
110
112
}
@@ -135,11 +137,13 @@ impl<'a> TestRouter<'a> {
135
137
scorer : & ' a RwLock < TestScorer > ,
136
138
) -> Self {
137
139
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 ( ) ) ;
138
142
Self {
139
143
router : DefaultRouter :: new ( network_graph. clone ( ) , logger, entropy_source, scorer, Default :: default ( ) ) ,
140
144
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,
143
147
scorer,
144
148
}
145
149
}
@@ -350,14 +354,19 @@ pub struct TestChainMonitor<'a> {
350
354
}
351
355
impl < ' a > TestChainMonitor < ' a > {
352
356
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 ) ;
353
362
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,
357
366
chain_monitor : chainmonitor:: ChainMonitor :: new ( chain_source, broadcaster, logger, fee_estimator, persister) ,
358
367
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,
361
370
}
362
371
}
363
372
@@ -449,10 +458,12 @@ pub(crate) struct WatchtowerPersister {
449
458
impl WatchtowerPersister {
450
459
#[ cfg( test) ]
451
460
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 ( ) ) ;
452
463
WatchtowerPersister {
453
464
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,
456
467
destination_script,
457
468
}
458
469
}
@@ -551,10 +562,13 @@ pub struct TestPersister {
551
562
}
552
563
impl TestPersister {
553
564
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 ( ) ) ;
554
568
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
558
572
}
559
573
}
560
574
@@ -693,14 +707,17 @@ pub struct TestBroadcaster {
693
707
694
708
impl TestBroadcaster {
695
709
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 ) ] ) ) ;
696
712
Self {
697
- txn_broadcasted : Mutex :: new ( Vec :: new ( ) ) ,
698
- blocks : Arc :: new ( Mutex :: new ( vec ! [ ( genesis_block ( network ) , 0 ) ] ) ) ,
713
+ txn_broadcasted,
714
+ blocks,
699
715
}
700
716
}
701
717
702
718
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 }
704
721
}
705
722
706
723
pub fn txn_broadcast ( & self ) -> Vec < Transaction > {
@@ -748,10 +765,13 @@ impl TestChannelMessageHandler {
748
765
749
766
impl TestChannelMessageHandler {
750
767
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 ( ) ) ;
751
771
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,
755
775
chain_hash,
756
776
}
757
777
}
@@ -990,10 +1010,11 @@ pub struct TestRoutingMessageHandler {
990
1010
991
1011
impl TestRoutingMessageHandler {
992
1012
pub fn new ( ) -> Self {
1013
+ let pending_events = Mutex :: new ( vec ! [ ] ) ;
993
1014
TestRoutingMessageHandler {
994
1015
chan_upds_recvd : AtomicUsize :: new ( 0 ) ,
995
1016
chan_anns_recvd : AtomicUsize :: new ( 0 ) ,
996
- pending_events : Mutex :: new ( vec ! [ ] ) ,
1017
+ pending_events,
997
1018
request_full_sync : AtomicBool :: new ( false ) ,
998
1019
announcement_available_for_sync : AtomicBool :: new ( false ) ,
999
1020
}
@@ -1108,10 +1129,12 @@ impl TestLogger {
1108
1129
Self :: with_id ( "" . to_owned ( ) )
1109
1130
}
1110
1131
pub fn with_id ( id : String ) -> TestLogger {
1132
+ let lines = Mutex :: new ( new_hash_map ( ) ) ;
1133
+ let context = Mutex :: new ( new_hash_map ( ) ) ;
1111
1134
TestLogger {
1112
1135
id,
1113
- lines : Mutex :: new ( new_hash_map ( ) ) ,
1114
- context : Mutex :: new ( new_hash_map ( ) ) ,
1136
+ lines,
1137
+ context,
1115
1138
}
1116
1139
}
1117
1140
pub fn assert_log ( & self , module : & str , line : String , count : usize ) {
@@ -1324,13 +1347,17 @@ impl SignerProvider for TestKeysInterface {
1324
1347
impl TestKeysInterface {
1325
1348
pub fn new ( seed : & [ u8 ; 32 ] , network : Network ) -> Self {
1326
1349
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 ( ) ) ;
1327
1354
Self {
1328
1355
backing : sign:: PhantomKeysManager :: new ( seed, now. as_secs ( ) , now. subsec_nanos ( ) , seed) ,
1329
- override_random_bytes : Mutex :: new ( None ) ,
1356
+ override_random_bytes,
1330
1357
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,
1334
1361
}
1335
1362
}
1336
1363
@@ -1396,12 +1423,15 @@ pub struct TestChainSource {
1396
1423
impl TestChainSource {
1397
1424
pub fn new ( network : Network ) -> Self {
1398
1425
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 ( ) ) ;
1399
1429
Self {
1400
1430
chain_hash : ChainHash :: using_genesis_block ( network) ,
1401
- utxo_ret : Mutex :: new ( UtxoResult :: Sync ( Ok ( TxOut { value : Amount :: MAX , script_pubkey } ) ) ) ,
1431
+ utxo_ret,
1402
1432
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,
1405
1435
}
1406
1436
}
1407
1437
pub fn remove_watched_txn_and_outputs ( & self , outpoint : OutPoint , script_pubkey : ScriptBuf ) {
0 commit comments