@@ -1816,9 +1816,9 @@ fn monitor_update_claim_fail_no_response() {
1816
1816
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
1817
1817
}
1818
1818
1819
- // confirm_a_first and restore_b_before_conf are wholly unrelated to earlier bools and
1820
1819
// restore_b_before_conf has no meaning if !confirm_a_first
1821
- fn do_during_funding_monitor_fail ( confirm_a_first : bool , restore_b_before_conf : bool ) {
1820
+ // restore_b_before_lock has no meaning if confirm_a_first
1821
+ fn do_during_funding_monitor_fail ( confirm_a_first : bool , restore_b_before_conf : bool , restore_b_before_lock : bool ) {
1822
1822
// Test that if the monitor update generated by funding_transaction_generated fails we continue
1823
1823
// the channel setup happily after the update is restored.
1824
1824
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
@@ -1860,6 +1860,8 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
1860
1860
if confirm_a_first {
1861
1861
confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1862
1862
nodes[ 1 ] . node . handle_funding_locked ( & nodes[ 0 ] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendFundingLocked , nodes[ 1 ] . node. get_our_node_id( ) ) ) ;
1863
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1864
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1863
1865
} else {
1864
1866
assert ! ( !restore_b_before_conf) ;
1865
1867
confirm_transaction ( & nodes[ 1 ] , & funding_tx) ;
@@ -1878,20 +1880,32 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
1878
1880
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1879
1881
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1880
1882
}
1883
+ if !confirm_a_first && !restore_b_before_lock {
1884
+ confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1885
+ nodes[ 1 ] . node . handle_funding_locked ( & nodes[ 0 ] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendFundingLocked , nodes[ 1 ] . node. get_our_node_id( ) ) ) ;
1886
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1887
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1888
+ }
1881
1889
1882
1890
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Ok ( ( ) ) ) ;
1883
1891
let ( outpoint, latest_update, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1884
1892
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( outpoint, latest_update) ;
1885
1893
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1886
1894
1887
1895
let ( channel_id, ( announcement, as_update, bs_update) ) = if !confirm_a_first {
1888
- nodes[ 0 ] . node . handle_funding_locked ( & nodes[ 1 ] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendFundingLocked , nodes[ 0 ] . node. get_our_node_id( ) ) ) ;
1889
-
1890
- confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1891
- let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 1 ] , & nodes[ 0 ] ) ;
1892
- ( channel_id, create_chan_between_nodes_with_value_b ( & nodes[ 0 ] , & nodes[ 1 ] , & funding_locked) )
1896
+ if !restore_b_before_lock {
1897
+ let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
1898
+ ( channel_id, create_chan_between_nodes_with_value_b ( & nodes[ 1 ] , & nodes[ 0 ] , & funding_locked) )
1899
+ } else {
1900
+ nodes[ 0 ] . node . handle_funding_locked ( & nodes[ 1 ] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendFundingLocked , nodes[ 0 ] . node. get_our_node_id( ) ) ) ;
1901
+ confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1902
+ let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 1 ] , & nodes[ 0 ] ) ;
1903
+ ( channel_id, create_chan_between_nodes_with_value_b ( & nodes[ 0 ] , & nodes[ 1 ] , & funding_locked) )
1904
+ }
1893
1905
} else {
1894
1906
if restore_b_before_conf {
1907
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1908
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1895
1909
confirm_transaction ( & nodes[ 1 ] , & funding_tx) ;
1896
1910
}
1897
1911
let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
@@ -1911,9 +1925,10 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
1911
1925
1912
1926
#[ test]
1913
1927
fn during_funding_monitor_fail ( ) {
1914
- do_during_funding_monitor_fail ( true , true ) ;
1915
- do_during_funding_monitor_fail ( true , false ) ;
1916
- do_during_funding_monitor_fail ( false , false ) ;
1928
+ do_during_funding_monitor_fail ( true , true , false ) ;
1929
+ do_during_funding_monitor_fail ( true , false , false ) ;
1930
+ do_during_funding_monitor_fail ( false , false , false ) ;
1931
+ do_during_funding_monitor_fail ( false , false , true ) ;
1917
1932
}
1918
1933
1919
1934
#[ test]
0 commit comments