@@ -1011,3 +1011,114 @@ fn fail_splice_on_tx_abort() {
1011
1011
let tx_abort = get_event_msg ! ( initiator, MessageSendEvent :: SendTxAbort , node_id_acceptor) ;
1012
1012
acceptor. node . handle_tx_abort ( node_id_initiator, & tx_abort) ;
1013
1013
}
1014
+
1015
+ #[ test]
1016
+ fn fail_splice_on_channel_close ( ) {
1017
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1018
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1019
+ let config = test_default_anchors_channel_config ( ) ;
1020
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( config. clone ( ) ) , Some ( config) ] ) ;
1021
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1022
+
1023
+ let initiator = & nodes[ 0 ] ;
1024
+ let acceptor = & nodes[ 1 ] ;
1025
+
1026
+ let _node_id_initiator = initiator. node . get_our_node_id ( ) ;
1027
+ let node_id_acceptor = acceptor. node . get_our_node_id ( ) ;
1028
+
1029
+ let initial_channel_capacity = 100_000 ;
1030
+ let ( _, _, channel_id, _) =
1031
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , initial_channel_capacity, 0 ) ;
1032
+
1033
+ let coinbase_tx = provide_anchor_reserves ( & nodes) ;
1034
+ let splice_in_amount = initial_channel_capacity / 2 ;
1035
+ let contribution = SpliceContribution :: SpliceIn {
1036
+ value : Amount :: from_sat ( splice_in_amount) ,
1037
+ inputs : vec ! [ FundingTxInput :: new_p2wpkh( coinbase_tx, 0 ) . unwrap( ) ] ,
1038
+ change_script : Some ( nodes[ 0 ] . wallet_source . get_change_script ( ) . unwrap ( ) ) ,
1039
+ } ;
1040
+
1041
+ // Close the channel before completion of interactive-tx construction.
1042
+ let _ = complete_splice_handshake ( initiator, acceptor, channel_id, contribution. clone ( ) ) ;
1043
+ let _tx_add_input =
1044
+ get_event_msg ! ( initiator, MessageSendEvent :: SendTxAddInput , node_id_acceptor) ;
1045
+
1046
+ initiator
1047
+ . node
1048
+ . force_close_broadcasting_latest_txn ( & channel_id, & node_id_acceptor, "test" . to_owned ( ) )
1049
+ . unwrap ( ) ;
1050
+ handle_bump_events ( initiator, true , 0 ) ;
1051
+ check_closed_events (
1052
+ & nodes[ 0 ] ,
1053
+ & [ ExpectedCloseEvent {
1054
+ channel_id : Some ( channel_id) ,
1055
+ discard_funding : false ,
1056
+ splice_failed : true ,
1057
+ channel_funding_txo : None ,
1058
+ user_channel_id : Some ( 42 ) ,
1059
+ ..Default :: default ( )
1060
+ } ] ,
1061
+ ) ;
1062
+ check_closed_broadcast ( & nodes[ 0 ] , 1 , true ) ;
1063
+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
1064
+ }
1065
+
1066
+ #[ test]
1067
+ fn fail_quiescent_action_on_channel_close ( ) {
1068
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1069
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1070
+ let config = test_default_anchors_channel_config ( ) ;
1071
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ Some ( config. clone ( ) ) , Some ( config) ] ) ;
1072
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1073
+
1074
+ let initiator = & nodes[ 0 ] ;
1075
+ let acceptor = & nodes[ 1 ] ;
1076
+
1077
+ let _node_id_initiator = initiator. node . get_our_node_id ( ) ;
1078
+ let node_id_acceptor = acceptor. node . get_our_node_id ( ) ;
1079
+
1080
+ let initial_channel_capacity = 100_000 ;
1081
+ let ( _, _, channel_id, _) =
1082
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , initial_channel_capacity, 0 ) ;
1083
+
1084
+ let coinbase_tx = provide_anchor_reserves ( & nodes) ;
1085
+ let splice_in_amount = initial_channel_capacity / 2 ;
1086
+ let contribution = SpliceContribution :: SpliceIn {
1087
+ value : Amount :: from_sat ( splice_in_amount) ,
1088
+ inputs : vec ! [ FundingTxInput :: new_p2wpkh( coinbase_tx, 0 ) . unwrap( ) ] ,
1089
+ change_script : Some ( nodes[ 0 ] . wallet_source . get_change_script ( ) . unwrap ( ) ) ,
1090
+ } ;
1091
+
1092
+ // Close the channel before completion of STFU handshake.
1093
+ initiator
1094
+ . node
1095
+ . splice_channel (
1096
+ & channel_id,
1097
+ & node_id_acceptor,
1098
+ contribution,
1099
+ FEERATE_FLOOR_SATS_PER_KW ,
1100
+ None ,
1101
+ )
1102
+ . unwrap ( ) ;
1103
+
1104
+ let _stfu_init = get_event_msg ! ( initiator, MessageSendEvent :: SendStfu , node_id_acceptor) ;
1105
+
1106
+ initiator
1107
+ . node
1108
+ . force_close_broadcasting_latest_txn ( & channel_id, & node_id_acceptor, "test" . to_owned ( ) )
1109
+ . unwrap ( ) ;
1110
+ handle_bump_events ( initiator, true , 0 ) ;
1111
+ check_closed_events (
1112
+ & nodes[ 0 ] ,
1113
+ & [ ExpectedCloseEvent {
1114
+ channel_id : Some ( channel_id) ,
1115
+ discard_funding : false ,
1116
+ splice_failed : true ,
1117
+ channel_funding_txo : None ,
1118
+ user_channel_id : Some ( 42 ) ,
1119
+ ..Default :: default ( )
1120
+ } ] ,
1121
+ ) ;
1122
+ check_closed_broadcast ( & nodes[ 0 ] , 1 , true ) ;
1123
+ check_added_monitors ( & nodes[ 0 ] , 1 ) ;
1124
+ }
0 commit comments