@@ -1211,9 +1211,7 @@ fn simple_target_feerate_shutdown() {
1211
1211
check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: CooperativeClosure , [ nodes[ 0 ] . node. get_our_node_id( ) ] , 100000 ) ;
1212
1212
}
1213
1213
1214
-
1215
- #[ test]
1216
- fn htlc_removal_no_early_closing_signed ( ) {
1214
+ fn do_outbound_update_no_early_closing_signed ( use_htlc : bool ) {
1217
1215
// Previously, if we have a pending inbound HTLC on a channel which has initiated shutdown,
1218
1216
// we'd send our initial closing_signed immediately after receiving the peer's last RAA to
1219
1217
// 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() {
1227
1225
let chan_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) . 2 ;
1228
1226
1229
1227
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 ) ;
1231
1247
1232
1248
nodes[ 1 ] . node . close_channel ( & chan_id, & nodes[ 0 ] . node . get_our_node_id ( ) ) . unwrap ( ) ;
1233
1249
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() {
1237
1253
nodes[ 0 ] . node . handle_shutdown ( & nodes[ 1 ] . node . get_our_node_id ( ) , & node_0_shutdown) ;
1238
1254
nodes[ 1 ] . node . handle_shutdown ( & nodes[ 0 ] . node . get_our_node_id ( ) , & node_1_shutdown) ;
1239
1255
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
+ }
1246
1261
nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. commitment_signed ) ;
1247
1262
check_added_monitors ( & nodes[ 1 ] , 1 ) ;
1248
1263
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() {
1271
1286
if let MessageSendEvent :: SendRevokeAndACK { msg, .. } = & as_raa_closing_signed[ 0 ] {
1272
1287
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) , & msg) ;
1273
1288
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
+ }
1275
1292
} else { panic ! ( "Unexpected message {:?}" , as_raa_closing_signed[ 0 ] ) ; }
1276
1293
1277
1294
if let MessageSendEvent :: SendClosingSigned { msg, .. } = & as_raa_closing_signed[ 1 ] {
@@ -1288,3 +1305,9 @@ fn htlc_removal_no_early_closing_signed() {
1288
1305
check_closed_event ! ( nodes[ 0 ] , 1 , ClosureReason :: CooperativeClosure , [ nodes[ 1 ] . node. get_our_node_id( ) ] , 100000 ) ;
1289
1306
check_closed_event ! ( nodes[ 1 ] , 1 , ClosureReason :: CooperativeClosure , [ nodes[ 0 ] . node. get_our_node_id( ) ] , 100000 ) ;
1290
1307
}
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