@@ -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,12 @@ 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.
922+ assert ! ( node_a. list_channels( ) . iter( ) . all( |c| matches!(
923+ c. channel_shutdown_state,
924+ None | Some ( ChannelShutdownState :: NotShuttingDown )
925+ ) ) ) ;
926+
921927 println ! ( "\n B receive" ) ;
922928 let invoice_amount_1_msat = 2500_000 ;
923929 let invoice_description: Bolt11InvoiceDescription =
@@ -1269,6 +1275,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
12691275 node_a. force_close_channel ( & user_channel_id_a, node_b. node_id ( ) , None ) . unwrap ( ) ;
12701276 } else {
12711277 node_a. close_channel ( & user_channel_id_a, node_b. node_id ( ) ) . unwrap ( ) ;
1278+ // The cooperative shutdown may complete before we get to check, but if the channel
1279+ // is still visible it must already be in a shutdown state.
1280+ if let Some ( channel) =
1281+ node_a. list_channels ( ) . into_iter ( ) . find ( |c| c. user_channel_id == user_channel_id_a)
1282+ {
1283+ assert ! (
1284+ !matches!(
1285+ channel. channel_shutdown_state,
1286+ None | Some ( ChannelShutdownState :: NotShuttingDown )
1287+ ) ,
1288+ "Expected shutdown in progress on node_a, got {:?}" ,
1289+ channel. channel_shutdown_state,
1290+ ) ;
1291+ }
12721292 }
12731293
12741294 expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments