@@ -32,8 +32,8 @@ use ldk_node::entropy::{generate_entropy_mnemonic, NodeEntropy};
3232use ldk_node:: io:: sqlite_store:: SqliteStore ;
3333use ldk_node:: payment:: { PaymentDirection , PaymentKind , PaymentStatus } ;
3434use ldk_node:: {
35- Builder , CustomTlvRecord , Event , LightningBalance , Node , NodeError , PendingSweepBalance ,
36- UserChannelId ,
35+ Builder , ChannelShutdownState , CustomTlvRecord , Event , LightningBalance , Node , NodeError ,
36+ PendingSweepBalance , UserChannelId ,
3737} ;
3838use lightning:: io;
3939use lightning:: ln:: msgs:: SocketAddress ;
@@ -916,6 +916,12 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
916916 let user_channel_id_a = expect_channel_ready_event ! ( node_a, node_b. node_id( ) ) ;
917917 let user_channel_id_b = expect_channel_ready_event ! ( node_b, node_a. node_id( ) ) ;
918918
919+ // After channel_ready, no shutdown should be in progress.
920+ assert ! ( node_a. list_channels( ) . iter( ) . all( |c| matches!(
921+ c. channel_shutdown_state,
922+ None | Some ( ChannelShutdownState :: NotShuttingDown )
923+ ) ) ) ;
924+
919925 println ! ( "\n B receive" ) ;
920926 let invoice_amount_1_msat = 2500_000 ;
921927 let invoice_description: Bolt11InvoiceDescription =
@@ -1267,6 +1273,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
12671273 node_a. force_close_channel ( & user_channel_id_a, node_b. node_id ( ) , None ) . unwrap ( ) ;
12681274 } else {
12691275 node_a. close_channel ( & user_channel_id_a, node_b. node_id ( ) ) . unwrap ( ) ;
1276+ // The cooperative shutdown may complete before we get to check, but if the channel
1277+ // is still visible it must already be in a shutdown state.
1278+ if let Some ( channel) =
1279+ node_a. list_channels ( ) . into_iter ( ) . find ( |c| c. user_channel_id == user_channel_id_a)
1280+ {
1281+ assert ! (
1282+ !matches!(
1283+ channel. channel_shutdown_state,
1284+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1285+ ) ,
1286+ "Expected shutdown in progress on node_a, got {:?}" ,
1287+ channel. channel_shutdown_state,
1288+ ) ;
1289+ }
12701290 }
12711291
12721292 expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments