@@ -1789,9 +1789,9 @@ fn monitor_update_claim_fail_no_response() {
1789
1789
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
1790
1790
}
1791
1791
1792
- // confirm_a_first and restore_b_before_conf are wholly unrelated to earlier bools and
1793
1792
// restore_b_before_conf has no meaning if !confirm_a_first
1794
- fn do_during_funding_monitor_fail ( confirm_a_first : bool , restore_b_before_conf : bool ) {
1793
+ // restore_b_before_lock has no meaning if confirm_a_first
1794
+ fn do_during_funding_monitor_fail ( confirm_a_first : bool , restore_b_before_conf : bool , restore_b_before_lock : bool ) {
1795
1795
// Test that if the monitor update generated by funding_transaction_generated fails we continue
1796
1796
// the channel setup happily after the update is restored.
1797
1797
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
@@ -1833,6 +1833,8 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
1833
1833
if confirm_a_first {
1834
1834
confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1835
1835
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( ) ) ) ;
1836
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1837
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1836
1838
} else {
1837
1839
assert ! ( !restore_b_before_conf) ;
1838
1840
confirm_transaction ( & nodes[ 1 ] , & funding_tx) ;
@@ -1851,20 +1853,32 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
1851
1853
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1852
1854
assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1853
1855
}
1856
+ if !confirm_a_first && !restore_b_before_lock {
1857
+ confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1858
+ 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( ) ) ) ;
1859
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1860
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1861
+ }
1854
1862
1855
1863
chanmon_cfgs[ 1 ] . persister . set_update_ret ( Ok ( ( ) ) ) ;
1856
1864
let ( outpoint, latest_update, _) = nodes[ 1 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & channel_id) . unwrap ( ) . clone ( ) ;
1857
1865
nodes[ 1 ] . chain_monitor . chain_monitor . force_channel_monitor_updated ( outpoint, latest_update) ;
1858
1866
check_added_monitors ! ( nodes[ 1 ] , 0 ) ;
1859
1867
1860
1868
let ( channel_id, ( announcement, as_update, bs_update) ) = if !confirm_a_first {
1861
- 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( ) ) ) ;
1862
-
1863
- confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1864
- let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 1 ] , & nodes[ 0 ] ) ;
1865
- ( channel_id, create_chan_between_nodes_with_value_b ( & nodes[ 0 ] , & nodes[ 1 ] , & funding_locked) )
1869
+ if !restore_b_before_lock {
1870
+ let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
1871
+ ( channel_id, create_chan_between_nodes_with_value_b ( & nodes[ 1 ] , & nodes[ 0 ] , & funding_locked) )
1872
+ } else {
1873
+ 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( ) ) ) ;
1874
+ confirm_transaction ( & nodes[ 0 ] , & funding_tx) ;
1875
+ let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 1 ] , & nodes[ 0 ] ) ;
1876
+ ( channel_id, create_chan_between_nodes_with_value_b ( & nodes[ 0 ] , & nodes[ 1 ] , & funding_locked) )
1877
+ }
1866
1878
} else {
1867
1879
if restore_b_before_conf {
1880
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
1881
+ assert ! ( nodes[ 1 ] . node. get_and_clear_pending_events( ) . is_empty( ) ) ;
1868
1882
confirm_transaction ( & nodes[ 1 ] , & funding_tx) ;
1869
1883
}
1870
1884
let ( funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
@@ -1884,9 +1898,10 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
1884
1898
1885
1899
#[ test]
1886
1900
fn during_funding_monitor_fail ( ) {
1887
- do_during_funding_monitor_fail ( true , true ) ;
1888
- do_during_funding_monitor_fail ( true , false ) ;
1889
- do_during_funding_monitor_fail ( false , false ) ;
1901
+ do_during_funding_monitor_fail ( true , true , false ) ;
1902
+ do_during_funding_monitor_fail ( true , false , false ) ;
1903
+ do_during_funding_monitor_fail ( false , false , false ) ;
1904
+ do_during_funding_monitor_fail ( false , false , true ) ;
1890
1905
}
1891
1906
1892
1907
#[ test]
0 commit comments