@@ -1281,3 +1281,114 @@ fn fail_splice_on_tx_abort() {
1281
1281
let tx_abort = get_event_msg ! ( initiator, MessageSendEvent :: SendTxAbort , node_id_acceptor) ;
1282
1282
acceptor. node . handle_tx_abort ( node_id_initiator, & tx_abort) ;
1283
1283
}
1284
+
1285
+ #[ test]
1286
+ fn fail_splice_on_channel_close ( ) {
1287
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1288
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1289
+ let config = test_default_anchors_channel_config ( ) ;
1290
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( config. clone ( ) ) , Some ( config) ] ) ;
1291
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1292
+
1293
+ let initiator = & nodes[ 0 ] ;
1294
+ let acceptor = & nodes[ 1 ] ;
1295
+
1296
+ let _node_id_initiator = initiator. node . get_our_node_id ( ) ;
1297
+ let node_id_acceptor = acceptor. node . get_our_node_id ( ) ;
1298
+
1299
+ let initial_channel_capacity = 100_000 ;
1300
+ let ( _, _, channel_id, _) =
1301
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , initial_channel_capacity, 0 ) ;
1302
+
1303
+ let coinbase_tx = provide_anchor_reserves ( & nodes) ;
1304
+ let splice_in_amount = initial_channel_capacity / 2 ;
1305
+ let contribution = SpliceContribution :: SpliceIn {
1306
+ value : Amount :: from_sat ( splice_in_amount) ,
1307
+ inputs : vec ! [ FundingTxInput :: new_p2wpkh( coinbase_tx, 0 ) . unwrap( ) ] ,
1308
+ change_script : Some ( nodes[ 0 ] . wallet_source . get_change_script ( ) . unwrap ( ) ) ,
1309
+ } ;
1310
+
1311
+ // Close the channel before completion of interactive-tx construction.
1312
+ let _ = complete_splice_handshake ( initiator, acceptor, channel_id, contribution. clone ( ) ) ;
1313
+ let _tx_add_input =
1314
+ get_event_msg ! ( initiator, MessageSendEvent :: SendTxAddInput , node_id_acceptor) ;
1315
+
1316
+ initiator
1317
+ . node
1318
+ . force_close_broadcasting_latest_txn ( & channel_id, & node_id_acceptor, "test" . to_owned ( ) )
1319
+ . unwrap ( ) ;
1320
+ handle_bump_events ( initiator, true , 0 ) ;
1321
+ check_closed_events (
1322
+ & nodes[ 0 ] ,
1323
+ & [ ExpectedCloseEvent {
1324
+ channel_id : Some ( channel_id) ,
1325
+ discard_funding : false ,
1326
+ splice_failed : true ,
1327
+ channel_funding_txo : None ,
1328
+ user_channel_id : Some ( 42 ) ,
1329
+ ..Default :: default ( )
1330
+ } ] ,
1331
+ ) ;
1332
+ check_closed_broadcast ( & nodes[ 0 ] , 1 , true ) ;
1333
+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
1334
+ }
1335
+
1336
+ #[ test]
1337
+ fn fail_quiescent_action_on_channel_close ( ) {
1338
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1339
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1340
+ let config = test_default_anchors_channel_config ( ) ;
1341
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( config. clone ( ) ) , Some ( config) ] ) ;
1342
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1343
+
1344
+ let initiator = & nodes[ 0 ] ;
1345
+ let acceptor = & nodes[ 1 ] ;
1346
+
1347
+ let _node_id_initiator = initiator. node . get_our_node_id ( ) ;
1348
+ let node_id_acceptor = acceptor. node . get_our_node_id ( ) ;
1349
+
1350
+ let initial_channel_capacity = 100_000 ;
1351
+ let ( _, _, channel_id, _) =
1352
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , initial_channel_capacity, 0 ) ;
1353
+
1354
+ let coinbase_tx = provide_anchor_reserves ( & nodes) ;
1355
+ let splice_in_amount = initial_channel_capacity / 2 ;
1356
+ let contribution = SpliceContribution :: SpliceIn {
1357
+ value : Amount :: from_sat ( splice_in_amount) ,
1358
+ inputs : vec ! [ FundingTxInput :: new_p2wpkh( coinbase_tx, 0 ) . unwrap( ) ] ,
1359
+ change_script : Some ( nodes[ 0 ] . wallet_source . get_change_script ( ) . unwrap ( ) ) ,
1360
+ } ;
1361
+
1362
+ // Close the channel before completion of STFU handshake.
1363
+ initiator
1364
+ . node
1365
+ . splice_channel (
1366
+ & channel_id,
1367
+ & node_id_acceptor,
1368
+ contribution,
1369
+ FEERATE_FLOOR_SATS_PER_KW ,
1370
+ None ,
1371
+ )
1372
+ . unwrap ( ) ;
1373
+
1374
+ let _stfu_init = get_event_msg ! ( initiator, MessageSendEvent :: SendStfu , 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
+ }
0 commit comments