-
Notifications
You must be signed in to change notification settings - Fork 130
Expose ChannelDetails::channel_shutdown_state
#827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,8 @@ use ldk_node::entropy::{generate_entropy_mnemonic, NodeEntropy}; | |
| use ldk_node::io::sqlite_store::SqliteStore; | ||
| use ldk_node::payment::{PaymentDirection, PaymentKind, PaymentStatus}; | ||
| use ldk_node::{ | ||
| Builder, CustomTlvRecord, Event, LightningBalance, Node, NodeError, PendingSweepBalance, | ||
| UserChannelId, | ||
| Builder, ChannelShutdownState, CustomTlvRecord, Event, LightningBalance, Node, NodeError, | ||
| PendingSweepBalance, UserChannelId, | ||
| }; | ||
| use lightning::io; | ||
| use lightning::ln::msgs::SocketAddress; | ||
|
|
@@ -918,6 +918,28 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>( | |
| let user_channel_id_a = expect_channel_ready_event!(node_a, node_b.node_id()); | ||
| let user_channel_id_b = expect_channel_ready_event!(node_b, node_a.node_id()); | ||
|
|
||
| // After channel_ready, no shutdown should be in progress on either side. | ||
| for channel in node_a.list_channels() { | ||
| assert!( | ||
| matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| ), | ||
| "Expected no shutdown in progress on node_a, got {:?}", | ||
| channel.channel_shutdown_state, | ||
| ); | ||
| } | ||
| for channel in node_b.list_channels() { | ||
| assert!( | ||
| matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| ), | ||
| "Expected no shutdown in progress on node_b, got {:?}", | ||
| channel.channel_shutdown_state, | ||
| ); | ||
| } | ||
|
|
||
| println!("\nB receive"); | ||
| let invoice_amount_1_msat = 2500_000; | ||
| let invoice_description: Bolt11InvoiceDescription = | ||
|
|
@@ -1233,6 +1255,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>( | |
| expect_channel_ready_event!(node_a, node_b.node_id()); | ||
| expect_channel_ready_event!(node_b, node_a.node_id()); | ||
|
|
||
| // After the splice-out, the channel must still report no shutdown in progress. | ||
| for channel in node_a.list_channels() { | ||
| assert!(matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| )); | ||
| } | ||
| for channel in node_b.list_channels() { | ||
| assert!(matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| )); | ||
| } | ||
|
|
||
| assert_eq!( | ||
| node_a | ||
| .list_payments_with_filter(|p| p.direction == PaymentDirection::Inbound | ||
|
|
@@ -1255,6 +1291,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>( | |
| expect_channel_ready_event!(node_a, node_b.node_id()); | ||
| expect_channel_ready_event!(node_b, node_a.node_id()); | ||
|
|
||
| // After the splice-in, the channel must still report no shutdown in progress. | ||
| for channel in node_a.list_channels() { | ||
| assert!(matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| )); | ||
| } | ||
| for channel in node_b.list_channels() { | ||
| assert!(matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| )); | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, if we add all these assertions for
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have been trying to test this part, but the problem is that for cooperative close, the shutdown completes very quickly in tests, so by the time we call In the force close phase, LDK doesn't use the cooperative shutdown state machine for force closes, so the field would still be |
||
| assert_eq!( | ||
| node_a | ||
| .list_payments_with_filter(|p| p.direction == PaymentDirection::Outbound | ||
|
|
@@ -1269,6 +1319,20 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>( | |
| node_a.force_close_channel(&user_channel_id_a, node_b.node_id(), None).unwrap(); | ||
| } else { | ||
| node_a.close_channel(&user_channel_id_a, node_b.node_id()).unwrap(); | ||
| // The cooperative shutdown may complete before we get to check, but if the channel | ||
| // is still visible it must already be in a shutdown state. | ||
| if let Some(channel) = | ||
| node_a.list_channels().into_iter().find(|c| c.user_channel_id == user_channel_id_a) | ||
| { | ||
| assert!( | ||
| !matches!( | ||
| channel.channel_shutdown_state, | ||
| None | Some(ChannelShutdownState::NotShuttingDown) | ||
| ), | ||
| "Expected shutdown in progress on node_a, got {:?}", | ||
| channel.channel_shutdown_state, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| expect_event!(node_a, ChannelClosed); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a note that this will be
Nonefor objects first serialized with LDK Node v0.1.