@@ -1629,12 +1629,9 @@ fn monitor_update_claim_fail_no_response() {
1629
1629
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, 1_000_000 ) ;
1630
1630
}
1631
1631
1632
- // Note that restore_between_fails with !fail_on_generate is useless
1633
- // Also note that !fail_on_generate && !fail_on_signed is useless
1634
- // Finally, note that !fail_on_signed is not possible with fail_on_generate && !restore_between_fails
1635
1632
// confirm_a_first and restore_b_before_conf are wholly unrelated to earlier bools and
1636
1633
// restore_b_before_conf has no meaning if !confirm_a_first
1637
- fn do_during_funding_monitor_fail ( fail_on_generate : bool , restore_between_fails : bool , fail_on_signed : bool , confirm_a_first : bool , restore_b_before_conf : bool ) {
1634
+ fn do_during_funding_monitor_fail ( confirm_a_first : bool , restore_b_before_conf : bool ) {
1638
1635
// Test that if the monitor update generated by funding_transaction_generated fails we continue
1639
1636
// the channel setup happily after the update is restored.
1640
1637
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
@@ -1648,52 +1645,25 @@ fn do_during_funding_monitor_fail(fail_on_generate: bool, restore_between_fails:
1648
1645
1649
1646
let ( temporary_channel_id, funding_tx, funding_output) = create_funding_transaction ( & nodes[ 0 ] , 100000 , 43 ) ;
1650
1647
1651
- if fail_on_generate {
1652
- * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
1653
- }
1654
1648
nodes[ 0 ] . node . funding_transaction_generated ( & temporary_channel_id, funding_output) ;
1655
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1649
+ check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
1656
1650
1657
1651
* nodes[ 1 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
1658
1652
let funding_created_msg = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendFundingCreated , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1659
1653
let channel_id = OutPoint { txid : funding_created_msg. funding_txid , index : funding_created_msg. funding_output_index } . to_channel_id ( ) ;
1660
1654
nodes[ 1 ] . node . handle_funding_created ( & nodes[ 0 ] . node . get_our_node_id ( ) , & funding_created_msg) ;
1661
1655
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1662
1656
1663
- if restore_between_fails {
1664
- assert ! ( fail_on_generate) ;
1665
- * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1666
- let ( outpoint, latest_update) = nodes[ 0 ] . chan_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1667
- nodes[ 0 ] . node . channel_monitor_updated ( & outpoint, latest_update) ;
1668
- check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
1669
- assert ! ( nodes[ 0 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1670
- assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1671
- }
1672
-
1673
- if fail_on_signed {
1674
- * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
1675
- } else {
1676
- assert ! ( restore_between_fails || !fail_on_generate) ; // We can't switch to good now (there's no monitor update)
1677
- assert ! ( fail_on_generate) ; // Somebody has to fail
1678
- }
1657
+ * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ;
1679
1658
nodes[ 0 ] . node . handle_funding_signed ( & nodes[ 1 ] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendFundingSigned , nodes[ 0 ] . node. get_our_node_id( ) ) ) ;
1680
- if fail_on_signed || !restore_between_fails {
1681
- assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1682
- if fail_on_generate && !restore_between_fails {
1683
- nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Previous monitor update failure prevented funding_signed from allowing funding broadcast" . to_string ( ) , 1 ) ;
1684
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1685
- } else {
1686
- nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Failed to update ChannelMonitor" . to_string ( ) , 1 ) ;
1687
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1688
- }
1689
- assert ! ( nodes[ 0 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1690
- * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1691
- let ( outpoint, latest_update) = nodes[ 0 ] . chan_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1692
- nodes[ 0 ] . node . channel_monitor_updated ( & outpoint, latest_update) ;
1693
- check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
1694
- } else {
1695
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1696
- }
1659
+ assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1660
+ nodes[ 0 ] . logger . assert_log ( "lightning::ln::channelmanager" . to_string ( ) , "Failed to update ChannelMonitor" . to_string ( ) , 1 ) ;
1661
+ check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1662
+ assert ! ( nodes[ 0 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1663
+ * nodes[ 0 ] . chan_monitor . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1664
+ let ( outpoint, latest_update) = nodes[ 0 ] . chan_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1665
+ nodes[ 0 ] . node . channel_monitor_updated ( & outpoint, latest_update) ;
1666
+ check_added_monitors ! ( nodes[ 0 ] , 0 ) ;
1697
1667
1698
1668
let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
1699
1669
assert_eq ! ( events. len( ) , 1 ) ;
@@ -1757,8 +1727,7 @@ fn do_during_funding_monitor_fail(fail_on_generate: bool, restore_between_fails:
1757
1727
1758
1728
#[ test]
1759
1729
fn during_funding_monitor_fail ( ) {
1760
- do_during_funding_monitor_fail ( false , false , true , true , true ) ;
1761
- do_during_funding_monitor_fail ( true , false , true , false , false ) ;
1762
- do_during_funding_monitor_fail ( true , true , true , true , false ) ;
1763
- do_during_funding_monitor_fail ( true , true , false , false , false ) ;
1730
+ do_during_funding_monitor_fail ( true , true ) ;
1731
+ do_during_funding_monitor_fail ( true , false ) ;
1732
+ do_during_funding_monitor_fail ( false , false ) ;
1764
1733
}
0 commit comments