@@ -19,11 +19,10 @@ use bitcoin::network::constants::Network;
19
19
use crate :: chain:: channelmonitor:: { ANTI_REORG_DELAY , ChannelMonitor } ;
20
20
use crate :: chain:: transaction:: OutPoint ;
21
21
use crate :: chain:: { ChannelMonitorUpdateStatus , Listen , Watch } ;
22
- use crate :: ln:: channelmanager:: { self , ChannelManager , ChannelManagerReadArgs , RAACommitmentOrder , PaymentSendFailure , PaymentId } ;
22
+ use crate :: ln:: channelmanager:: { self , ChannelManager , RAACommitmentOrder , PaymentSendFailure , PaymentId } ;
23
23
use crate :: ln:: channel:: AnnouncementSigsState ;
24
24
use crate :: ln:: msgs;
25
25
use crate :: ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
26
- use crate :: util:: config:: UserConfig ;
27
26
use crate :: util:: enforcing_trait_impls:: EnforcingSigner ;
28
27
use crate :: util:: events:: { Event , MessageSendEvent , MessageSendEventsProvider , PaymentPurpose , ClosureReason , HTLCDestination } ;
29
28
use crate :: util:: errors:: APIError ;
@@ -2294,40 +2293,8 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2294
2293
// disconnect the peers. Note that the fuzzer originally found this issue because
2295
2294
// deserializing a ChannelManager in this state causes an assertion failure.
2296
2295
if reload_a {
2297
- let nodes_0_serialized = nodes[ 0 ] . node . encode ( ) ;
2298
- let mut chan_0_monitor_serialized = test_utils:: TestVecWriter ( Vec :: new ( ) ) ;
2299
- get_monitor ! ( nodes[ 0 ] , chan_id) . write ( & mut chan_0_monitor_serialized) . unwrap ( ) ;
2300
-
2301
- persister = test_utils:: TestPersister :: new ( ) ;
2302
- let keys_manager = & chanmon_cfgs[ 0 ] . keys_manager ;
2303
- new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , nodes[ 0 ] . logger , node_cfgs[ 0 ] . fee_estimator , & persister, keys_manager) ;
2304
- nodes[ 0 ] . chain_monitor = & new_chain_monitor;
2305
- let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
2306
- let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingSigner > ) >:: read (
2307
- & mut chan_0_monitor_read, keys_manager) . unwrap ( ) ;
2308
- assert ! ( chan_0_monitor_read. is_empty( ) ) ;
2309
-
2310
- let mut nodes_0_read = & nodes_0_serialized[ ..] ;
2311
- let config = UserConfig :: default ( ) ;
2312
- nodes_0_deserialized = {
2313
- let mut channel_monitors = HashMap :: new ( ) ;
2314
- channel_monitors. insert ( chan_0_monitor. get_funding_txo ( ) . 0 , & mut chan_0_monitor) ;
2315
- <( BlockHash , ChannelManager < & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ) >:: read ( & mut nodes_0_read, ChannelManagerReadArgs {
2316
- default_config : config,
2317
- keys_manager,
2318
- fee_estimator : node_cfgs[ 0 ] . fee_estimator ,
2319
- chain_monitor : nodes[ 0 ] . chain_monitor ,
2320
- tx_broadcaster : nodes[ 0 ] . tx_broadcaster . clone ( ) ,
2321
- logger : nodes[ 0 ] . logger ,
2322
- channel_monitors,
2323
- } ) . unwrap ( ) . 1
2324
- } ;
2325
- nodes[ 0 ] . node = & nodes_0_deserialized;
2326
- assert ! ( nodes_0_read. is_empty( ) ) ;
2327
-
2328
- assert_eq ! ( nodes[ 0 ] . chain_monitor. watch_channel( chan_0_monitor. get_funding_txo( ) . 0 . clone( ) , chan_0_monitor) ,
2329
- ChannelMonitorUpdateStatus :: Completed ) ;
2330
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
2296
+ let chan_0_monitor_serialized = get_monitor ! ( nodes[ 0 ] , chan_id) . encode ( ) ;
2297
+ reload_node ! ( nodes[ 0 ] , & nodes[ 0 ] . node. encode( ) , & [ & chan_0_monitor_serialized] , persister, new_chain_monitor, nodes_0_deserialized) ;
2331
2298
} else {
2332
2299
nodes[ 0 ] . node . peer_disconnected ( & nodes[ 1 ] . node . get_our_node_id ( ) , false ) ;
2333
2300
}
@@ -2832,28 +2799,7 @@ fn do_test_outbound_reload_without_init_mon(use_0conf: bool) {
2832
2799
nodes[ 0 ] . chain_source . watched_txn . lock ( ) . unwrap ( ) . clear ( ) ;
2833
2800
nodes[ 0 ] . chain_source . watched_outputs . lock ( ) . unwrap ( ) . clear ( ) ;
2834
2801
2835
- let nodes_0_serialized = nodes[ 0 ] . node . encode ( ) ;
2836
- persister = test_utils:: TestPersister :: new ( ) ;
2837
- let keys_manager = & chanmon_cfgs[ 0 ] . keys_manager ;
2838
- new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , nodes[ 0 ] . logger , node_cfgs[ 0 ] . fee_estimator , & persister, keys_manager) ;
2839
- nodes[ 0 ] . chain_monitor = & new_chain_monitor;
2840
-
2841
- let mut nodes_0_read = & nodes_0_serialized[ ..] ;
2842
- let config = UserConfig :: default ( ) ;
2843
- nodes_0_deserialized = {
2844
- <( BlockHash , ChannelManager < & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ) >:: read ( & mut nodes_0_read, ChannelManagerReadArgs {
2845
- default_config : config,
2846
- keys_manager,
2847
- fee_estimator : node_cfgs[ 0 ] . fee_estimator ,
2848
- chain_monitor : nodes[ 0 ] . chain_monitor ,
2849
- tx_broadcaster : nodes[ 0 ] . tx_broadcaster . clone ( ) ,
2850
- logger : nodes[ 0 ] . logger ,
2851
- channel_monitors : HashMap :: new ( ) ,
2852
- } ) . unwrap ( ) . 1
2853
- } ;
2854
- nodes[ 0 ] . node = & nodes_0_deserialized;
2855
- assert ! ( nodes_0_read. is_empty( ) ) ;
2856
-
2802
+ reload_node ! ( nodes[ 0 ] , & nodes[ 0 ] . node. encode( ) , & [ ] , persister, new_chain_monitor, nodes_0_deserialized) ;
2857
2803
check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: DisconnectedPeer ) ;
2858
2804
assert ! ( nodes[ 0 ] . node. list_channels( ) . is_empty( ) ) ;
2859
2805
}
@@ -2938,27 +2884,7 @@ fn do_test_inbound_reload_without_init_mon(use_0conf: bool, lock_commitment: boo
2938
2884
nodes[ 1 ] . chain_source . watched_txn . lock ( ) . unwrap ( ) . clear ( ) ;
2939
2885
nodes[ 1 ] . chain_source . watched_outputs . lock ( ) . unwrap ( ) . clear ( ) ;
2940
2886
2941
- let nodes_1_serialized = nodes[ 1 ] . node . encode ( ) ;
2942
- persister = test_utils:: TestPersister :: new ( ) ;
2943
- let keys_manager = & chanmon_cfgs[ 1 ] . keys_manager ;
2944
- new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 1 ] . chain_source ) , nodes[ 1 ] . tx_broadcaster . clone ( ) , nodes[ 1 ] . logger , node_cfgs[ 1 ] . fee_estimator , & persister, keys_manager) ;
2945
- nodes[ 1 ] . chain_monitor = & new_chain_monitor;
2946
-
2947
- let mut nodes_1_read = & nodes_1_serialized[ ..] ;
2948
- let config = UserConfig :: default ( ) ;
2949
- nodes_1_deserialized = {
2950
- <( BlockHash , ChannelManager < & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ) >:: read ( & mut nodes_1_read, ChannelManagerReadArgs {
2951
- default_config : config,
2952
- keys_manager,
2953
- fee_estimator : node_cfgs[ 1 ] . fee_estimator ,
2954
- chain_monitor : nodes[ 1 ] . chain_monitor ,
2955
- tx_broadcaster : nodes[ 1 ] . tx_broadcaster . clone ( ) ,
2956
- logger : nodes[ 1 ] . logger ,
2957
- channel_monitors : HashMap :: new ( ) ,
2958
- } ) . unwrap ( ) . 1
2959
- } ;
2960
- nodes[ 1 ] . node = & nodes_1_deserialized;
2961
- assert ! ( nodes_1_read. is_empty( ) ) ;
2887
+ reload_node ! ( nodes[ 1 ] , & nodes[ 1 ] . node. encode( ) , & [ ] , persister, new_chain_monitor, nodes_1_deserialized) ;
2962
2888
2963
2889
check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: DisconnectedPeer ) ;
2964
2890
assert ! ( nodes[ 1 ] . node. list_channels( ) . is_empty( ) ) ;
0 commit comments