@@ -1211,9 +1211,7 @@ fn simple_target_feerate_shutdown() {
12111211 check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: CooperativeClosure , [ nodes[ 0 ] . node. get_our_node_id( ) ] , 100000 ) ;
12121212}
12131213
1214-
1215- #[ test]
1216- fn htlc_removal_no_early_closing_signed ( ) {
1214+ fn do_outbound_update_no_early_closing_signed ( use_htlc : bool ) {
12171215 // Previously, if we have a pending inbound HTLC on a channel which has initiated shutdown,
12181216 // we'd send our initial closing_signed immediately after receiving the peer's last RAA to
12191217 // remove the HTLC, but before receiving their final commitment_signed for a commitment without
@@ -1227,7 +1225,25 @@ fn htlc_removal_no_early_closing_signed() {
12271225 let chan_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) . 2 ;
12281226
12291227 send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1_000_000 ) ;
1230- let payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 10_000 ) . 1 ;
1228+ let payment_hash_opt = if use_htlc {
1229+ Some ( route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 10_000 ) . 1 )
1230+ } else {
1231+ None
1232+ } ;
1233+
1234+ if use_htlc {
1235+ nodes[ 0 ] . node . fail_htlc_backwards ( & payment_hash_opt. unwrap ( ) ) ;
1236+ expect_pending_htlcs_forwardable_and_htlc_handling_failed ! ( nodes[ 0 ] ,
1237+ [ HTLCDestination :: FailedPayment { payment_hash: payment_hash_opt. unwrap( ) } ] ) ;
1238+ } else {
1239+ {
1240+ let mut feerate_lock = chanmon_cfgs[ 0 ] . fee_estimator . sat_per_kw . lock ( ) . unwrap ( ) ;
1241+ * feerate_lock *= 10 ;
1242+ }
1243+ nodes[ 0 ] . node . timer_tick_occurred ( ) ;
1244+ }
1245+ let updates = get_htlc_update_msgs ( & nodes[ 0 ] , & nodes[ 1 ] . node . get_our_node_id ( ) ) ;
1246+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
12311247
12321248 nodes[ 1 ] . node . close_channel ( & chan_id, & nodes[ 0 ] . node . get_our_node_id ( ) ) . unwrap ( ) ;
12331249 let node_0_shutdown = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendShutdown , nodes[ 0 ] . node. get_our_node_id( ) ) ;
@@ -1237,12 +1253,11 @@ fn htlc_removal_no_early_closing_signed() {
12371253 nodes[ 0 ] . node . handle_shutdown ( & nodes[ 1 ] . node . get_our_node_id ( ) , & node_0_shutdown) ;
12381254 nodes[ 1 ] . node . handle_shutdown ( & nodes[ 0 ] . node . get_our_node_id ( ) , & node_1_shutdown) ;
12391255
1240- nodes[ 0 ] . node . fail_htlc_backwards ( & payment_hash) ;
1241- expect_pending_htlcs_forwardable_and_htlc_handling_failed ! ( nodes[ 0 ] , [ HTLCDestination :: FailedPayment { payment_hash } ] ) ;
1242- let updates = get_htlc_update_msgs ( & nodes[ 0 ] , & nodes[ 1 ] . node . get_our_node_id ( ) ) ;
1243- check_added_monitors ( & nodes[ 0 ] , 1 ) ;
1244-
1245- nodes[ 1 ] . node . handle_update_fail_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
1256+ if use_htlc {
1257+ nodes[ 1 ] . node . handle_update_fail_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
1258+ } else {
1259+ nodes[ 1 ] . node . handle_update_fee ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. update_fee . unwrap ( ) ) ;
1260+ }
12461261 nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. commitment_signed ) ;
12471262 check_added_monitors ( & nodes[ 1 ] , 1 ) ;
12481263 let ( bs_raa, bs_cs) = get_revoke_commit_msgs ( & nodes[ 1 ] , & nodes[ 0 ] . node . get_our_node_id ( ) ) ;
@@ -1271,7 +1286,9 @@ fn htlc_removal_no_early_closing_signed() {
12711286 if let MessageSendEvent :: SendRevokeAndACK { msg, .. } = & as_raa_closing_signed[ 0 ] {
12721287 nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) , & msg) ;
12731288 check_added_monitors ( & nodes[ 1 ] , 1 ) ;
1274- expect_payment_failed ! ( nodes[ 1 ] , payment_hash, true ) ;
1289+ if use_htlc {
1290+ expect_payment_failed ! ( nodes[ 1 ] , payment_hash_opt. unwrap( ) , true ) ;
1291+ }
12751292 } else { panic ! ( "Unexpected message {:?}" , as_raa_closing_signed[ 0 ] ) ; }
12761293
12771294 if let MessageSendEvent :: SendClosingSigned { msg, .. } = & as_raa_closing_signed[ 1 ] {
@@ -1288,3 +1305,9 @@ fn htlc_removal_no_early_closing_signed() {
12881305 check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: CooperativeClosure , [ nodes[ 1 ] . node. get_our_node_id( ) ] , 100000 ) ;
12891306 check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: CooperativeClosure , [ nodes[ 0 ] . node. get_our_node_id( ) ] , 100000 ) ;
12901307}
1308+
1309+ #[ test]
1310+ fn outbound_update_no_early_closing_signed ( ) {
1311+ do_outbound_update_no_early_closing_signed ( true ) ;
1312+ do_outbound_update_no_early_closing_signed ( false ) ;
1313+ }
0 commit comments