@@ -1341,3 +1341,114 @@ fn fail_splice_on_tx_abort() {
1341
1341
let tx_abort = get_event_msg ! ( initiator, MessageSendEvent :: SendTxAbort , node_id_acceptor) ;
1342
1342
acceptor. node . handle_tx_abort ( node_id_initiator, & tx_abort) ;
1343
1343
}
1344
+
1345
+ #[ test]
1346
+ fn fail_splice_on_channel_close ( ) {
1347
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1348
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1349
+ let config = test_default_anchors_channel_config ( ) ;
1350
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( config. clone ( ) ) , Some ( config) ] ) ;
1351
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1352
+
1353
+ let initiator = & nodes[ 0 ] ;
1354
+ let acceptor = & nodes[ 1 ] ;
1355
+
1356
+ let _node_id_initiator = initiator. node . get_our_node_id ( ) ;
1357
+ let node_id_acceptor = acceptor. node . get_our_node_id ( ) ;
1358
+
1359
+ let initial_channel_capacity = 100_000 ;
1360
+ let ( _, _, channel_id, _) =
1361
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , initial_channel_capacity, 0 ) ;
1362
+
1363
+ let coinbase_tx = provide_anchor_reserves ( & nodes) ;
1364
+ let splice_in_amount = initial_channel_capacity / 2 ;
1365
+ let contribution = SpliceContribution :: SpliceIn {
1366
+ value : Amount :: from_sat ( splice_in_amount) ,
1367
+ inputs : vec ! [ FundingTxInput :: new_p2wpkh( coinbase_tx, 0 ) . unwrap( ) ] ,
1368
+ change_script : Some ( nodes[ 0 ] . wallet_source . get_change_script ( ) . unwrap ( ) ) ,
1369
+ } ;
1370
+
1371
+ // Close the channel before completion of interactive-tx construction.
1372
+ let _ = complete_splice_handshake ( initiator, acceptor, channel_id, contribution. clone ( ) ) ;
1373
+ let _tx_add_input =
1374
+ get_event_msg ! ( initiator, MessageSendEvent :: SendTxAddInput , node_id_acceptor) ;
1375
+
1376
+ initiator
1377
+ . node
1378
+ . force_close_broadcasting_latest_txn ( & channel_id, & node_id_acceptor, "test" . to_owned ( ) )
1379
+ . unwrap ( ) ;
1380
+ handle_bump_events ( initiator, true , 0 ) ;
1381
+ check_closed_events (
1382
+ & nodes[ 0 ] ,
1383
+ & [ ExpectedCloseEvent {
1384
+ channel_id : Some ( channel_id) ,
1385
+ discard_funding : false ,
1386
+ splice_failed : true ,
1387
+ channel_funding_txo : None ,
1388
+ user_channel_id : Some ( 42 ) ,
1389
+ ..Default :: default ( )
1390
+ } ] ,
1391
+ ) ;
1392
+ check_closed_broadcast ( & nodes[ 0 ] , 1 , true ) ;
1393
+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
1394
+ }
1395
+
1396
+ #[ test]
1397
+ fn fail_quiescent_action_on_channel_close ( ) {
1398
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1399
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1400
+ let config = test_default_anchors_channel_config ( ) ;
1401
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( config. clone ( ) ) , Some ( config) ] ) ;
1402
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1403
+
1404
+ let initiator = & nodes[ 0 ] ;
1405
+ let acceptor = & nodes[ 1 ] ;
1406
+
1407
+ let _node_id_initiator = initiator. node . get_our_node_id ( ) ;
1408
+ let node_id_acceptor = acceptor. node . get_our_node_id ( ) ;
1409
+
1410
+ let initial_channel_capacity = 100_000 ;
1411
+ let ( _, _, channel_id, _) =
1412
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , initial_channel_capacity, 0 ) ;
1413
+
1414
+ let coinbase_tx = provide_anchor_reserves ( & nodes) ;
1415
+ let splice_in_amount = initial_channel_capacity / 2 ;
1416
+ let contribution = SpliceContribution :: SpliceIn {
1417
+ value : Amount :: from_sat ( splice_in_amount) ,
1418
+ inputs : vec ! [ FundingTxInput :: new_p2wpkh( coinbase_tx, 0 ) . unwrap( ) ] ,
1419
+ change_script : Some ( nodes[ 0 ] . wallet_source . get_change_script ( ) . unwrap ( ) ) ,
1420
+ } ;
1421
+
1422
+ // Close the channel before completion of STFU handshake.
1423
+ initiator
1424
+ . node
1425
+ . splice_channel (
1426
+ & channel_id,
1427
+ & node_id_acceptor,
1428
+ contribution,
1429
+ FEERATE_FLOOR_SATS_PER_KW ,
1430
+ None ,
1431
+ )
1432
+ . unwrap ( ) ;
1433
+
1434
+ let _stfu_init = get_event_msg ! ( initiator, MessageSendEvent :: SendStfu , node_id_acceptor) ;
1435
+
1436
+ initiator
1437
+ . node
1438
+ . force_close_broadcasting_latest_txn ( & channel_id, & node_id_acceptor, "test" . to_owned ( ) )
1439
+ . unwrap ( ) ;
1440
+ handle_bump_events ( initiator, true , 0 ) ;
1441
+ check_closed_events (
1442
+ & nodes[ 0 ] ,
1443
+ & [ ExpectedCloseEvent {
1444
+ channel_id : Some ( channel_id) ,
1445
+ discard_funding : false ,
1446
+ splice_failed : true ,
1447
+ channel_funding_txo : None ,
1448
+ user_channel_id : Some ( 42 ) ,
1449
+ ..Default :: default ( )
1450
+ } ] ,
1451
+ ) ;
1452
+ check_closed_broadcast ( & nodes[ 0 ] , 1 , true ) ;
1453
+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
1454
+ }
0 commit comments