@@ -31,8 +31,8 @@ use ldk_node::entropy::{generate_entropy_mnemonic, NodeEntropy};
3131use ldk_node:: io:: sqlite_store:: SqliteStore ;
3232use ldk_node:: payment:: { PaymentDirection , PaymentKind , PaymentStatus } ;
3333use ldk_node:: {
34- Builder , CustomTlvRecord , Event , LightningBalance , Node , NodeError , PendingSweepBalance ,
35- UserChannelId ,
34+ Builder , ChannelShutdownState , CustomTlvRecord , Event , LightningBalance , Node , NodeError ,
35+ PendingSweepBalance , UserChannelId ,
3636} ;
3737use lightning:: io;
3838use lightning:: ln:: msgs:: SocketAddress ;
@@ -918,6 +918,28 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
918918 let user_channel_id_a = expect_channel_ready_event ! ( node_a, node_b. node_id( ) ) ;
919919 let user_channel_id_b = expect_channel_ready_event ! ( node_b, node_a. node_id( ) ) ;
920920
921+ // After channel_ready, no shutdown should be in progress on either side.
922+ for channel in node_a. list_channels ( ) {
923+ assert ! (
924+ matches!(
925+ channel. channel_shutdown_state,
926+ None | Some ( ChannelShutdownState :: NotShuttingDown )
927+ ) ,
928+ "Expected no shutdown in progress on node_a, got {:?}" ,
929+ channel. channel_shutdown_state,
930+ ) ;
931+ }
932+ for channel in node_b. list_channels ( ) {
933+ assert ! (
934+ matches!(
935+ channel. channel_shutdown_state,
936+ None | Some ( ChannelShutdownState :: NotShuttingDown )
937+ ) ,
938+ "Expected no shutdown in progress on node_b, got {:?}" ,
939+ channel. channel_shutdown_state,
940+ ) ;
941+ }
942+
921943 println ! ( "\n B receive" ) ;
922944 let invoice_amount_1_msat = 2500_000 ;
923945 let invoice_description: Bolt11InvoiceDescription =
@@ -1233,6 +1255,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
12331255 expect_channel_ready_event ! ( node_a, node_b. node_id( ) ) ;
12341256 expect_channel_ready_event ! ( node_b, node_a. node_id( ) ) ;
12351257
1258+ // After the splice-out, the channel must still report no shutdown in progress.
1259+ for channel in node_a. list_channels ( ) {
1260+ assert ! ( matches!(
1261+ channel. channel_shutdown_state,
1262+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1263+ ) ) ;
1264+ }
1265+ for channel in node_b. list_channels ( ) {
1266+ assert ! ( matches!(
1267+ channel. channel_shutdown_state,
1268+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1269+ ) ) ;
1270+ }
1271+
12361272 assert_eq ! (
12371273 node_a
12381274 . list_payments_with_filter( |p| p. direction == PaymentDirection :: Inbound
@@ -1255,6 +1291,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
12551291 expect_channel_ready_event ! ( node_a, node_b. node_id( ) ) ;
12561292 expect_channel_ready_event ! ( node_b, node_a. node_id( ) ) ;
12571293
1294+ // After the splice-in, the channel must still report no shutdown in progress.
1295+ for channel in node_a. list_channels ( ) {
1296+ assert ! ( matches!(
1297+ channel. channel_shutdown_state,
1298+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1299+ ) ) ;
1300+ }
1301+ for channel in node_b. list_channels ( ) {
1302+ assert ! ( matches!(
1303+ channel. channel_shutdown_state,
1304+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1305+ ) ) ;
1306+ }
1307+
12581308 assert_eq ! (
12591309 node_a
12601310 . list_payments_with_filter( |p| p. direction == PaymentDirection :: Outbound
@@ -1269,6 +1319,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
12691319 node_a. force_close_channel ( & user_channel_id_a, node_b. node_id ( ) , None ) . unwrap ( ) ;
12701320 } else {
12711321 node_a. close_channel ( & user_channel_id_a, node_b. node_id ( ) ) . unwrap ( ) ;
1322+ // The cooperative shutdown may complete before we get to check, but if the channel
1323+ // is still visible it must already be in a shutdown state.
1324+ if let Some ( channel) =
1325+ node_a. list_channels ( ) . into_iter ( ) . find ( |c| c. user_channel_id == user_channel_id_a)
1326+ {
1327+ assert ! (
1328+ !matches!(
1329+ channel. channel_shutdown_state,
1330+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1331+ ) ,
1332+ "Expected shutdown in progress on node_a, got {:?}" ,
1333+ channel. channel_shutdown_state,
1334+ ) ;
1335+ }
12721336 }
12731337
12741338 expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments