@@ -783,7 +783,7 @@ fn test_forwardable_regen() {
783
783
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , payment_preimage_2) ;
784
784
}
785
785
786
- fn do_test_partial_claim_before_restart ( persist_both_monitors : bool ) {
786
+ fn do_test_partial_claim_before_restart ( persist_both_monitors : bool , double_restart : bool ) {
787
787
// Test what happens if a node receives an MPP payment, claims it, but crashes before
788
788
// persisting the ChannelManager. If `persist_both_monitors` is false, also crash after only
789
789
// updating one of the two channels' ChannelMonitors. As a result, on startup, we'll (a) still
@@ -799,11 +799,11 @@ fn do_test_partial_claim_before_restart(persist_both_monitors: bool) {
799
799
// definitely claimed.
800
800
let chanmon_cfgs = create_chanmon_cfgs ( 4 ) ;
801
801
let node_cfgs = create_node_cfgs ( 4 , & chanmon_cfgs) ;
802
- let persister ;
803
- let new_chain_monitor ;
802
+ let ( persist_d_1 , persist_d_2 ) ;
803
+ let ( chain_d_1 , chain_d_2 ) ;
804
804
805
805
let node_chanmgrs = create_node_chanmgrs ( 4 , & node_cfgs, & [ None , None , None , None ] ) ;
806
- let nodes_3_deserialized ;
806
+ let ( node_d_1 , node_d_2 ) ;
807
807
808
808
let mut nodes = create_network ( 4 , & node_cfgs, & node_chanmgrs) ;
809
809
@@ -878,7 +878,14 @@ fn do_test_partial_claim_before_restart(persist_both_monitors: bool) {
878
878
}
879
879
880
880
// Now restart nodes[3].
881
- reload_node ! ( nodes[ 3 ] , original_manager, & [ & updated_monitor. 0 , & original_monitor. 0 ] , persister, new_chain_monitor, nodes_3_deserialized) ;
881
+ reload_node ! ( nodes[ 3 ] , original_manager. clone( ) , & [ & updated_monitor. 0 , & original_monitor. 0 ] , persist_d_1, chain_d_1, node_d_1) ;
882
+
883
+ if double_restart {
884
+ // Previously, we had a bug where we'd fail to reload if we re-persist the `ChannelManager`
885
+ // without updating any `ChannelMonitor`s as we'd fail to double-initiate the claim replay.
886
+ // We test that here ensuring that we can reload again.
887
+ reload_node ! ( nodes[ 3 ] , node_d_1. encode( ) , & [ & updated_monitor. 0 , & original_monitor. 0 ] , persist_d_2, chain_d_2, node_d_2) ;
888
+ }
882
889
883
890
// Until the startup background events are processed (in `get_and_clear_pending_events`,
884
891
// below), the preimage is not copied to the non-persisted monitor...
@@ -973,8 +980,10 @@ fn do_test_partial_claim_before_restart(persist_both_monitors: bool) {
973
980
974
981
#[ test]
975
982
fn test_partial_claim_before_restart ( ) {
976
- do_test_partial_claim_before_restart ( false ) ;
977
- do_test_partial_claim_before_restart ( true ) ;
983
+ do_test_partial_claim_before_restart ( false , false ) ;
984
+ do_test_partial_claim_before_restart ( false , true ) ;
985
+ do_test_partial_claim_before_restart ( true , false ) ;
986
+ do_test_partial_claim_before_restart ( true , true ) ;
978
987
}
979
988
980
989
fn do_forwarded_payment_no_manager_persistence ( use_cs_commitment : bool , claim_htlc : bool , use_intercept : bool ) {
0 commit comments