Remove WriteableEcdsaChannelSigner trait
[rust-lightning] / lightning / src / ln / shutdown_tests.rs
index 9a44953f51e3fab76776f323ea91485a59ecc448..12421ce9c3f6323e31747173d4064572f5ae1198 100644 (file)
@@ -16,7 +16,8 @@ use crate::chain::transaction::OutPoint;
 use crate::events::{Event, MessageSendEvent, HTLCDestination, MessageSendEventsProvider, ClosureReason};
 use crate::ln::channelmanager::{self, PaymentSendFailure, PaymentId, RecipientOnionFields, Retry, ChannelShutdownState, ChannelDetails};
 use crate::routing::router::{PaymentParameters, get_route, RouteParameters};
-use crate::ln::{ChannelId, msgs};
+use crate::ln::msgs;
+use crate::ln::types::ChannelId;
 use crate::ln::msgs::{ChannelMessageHandler, ErrorAction};
 use crate::ln::onion_utils::INVALID_ONION_BLINDING;
 use crate::ln::script::ShutdownScript;
@@ -1430,23 +1431,32 @@ fn batch_funding_failure() {
        nodes[0].node.batch_funding_transaction_generated(&chans, tx).unwrap_err();
 
        let msgs = nodes[0].node.get_and_clear_pending_msg_events();
-       assert_eq!(msgs.len(), 2);
+       assert_eq!(msgs.len(), 3);
        // We currently spuriously send `FundingCreated` for the first channel and then immediately
        // fail both channels, which isn't ideal but should be fine.
        assert!(msgs.iter().any(|msg| {
                if let MessageSendEvent::HandleError { action: msgs::ErrorAction::SendErrorMessage {
                        msg: msgs::ErrorMessage { channel_id, .. }, ..
                }, .. } = msg {
-                       assert_eq!(*channel_id, temp_chan_id_b);
-                       true
+                       *channel_id == temp_chan_id_b
                } else { false }
        }));
-       assert!(msgs.iter().any(|msg| {
+       let funding_created_pos = msgs.iter().position(|msg| {
                if let MessageSendEvent::SendFundingCreated { msg: msgs::FundingCreated { temporary_channel_id, .. }, .. } = msg {
                        assert_eq!(*temporary_channel_id, temp_chan_id_a);
                        true
                } else { false }
-       }));
+       }).unwrap();
+       let funded_channel_close_pos = msgs.iter().position(|msg| {
+               if let MessageSendEvent::HandleError { action: msgs::ErrorAction::SendErrorMessage {
+                       msg: msgs::ErrorMessage { channel_id, .. }, ..
+               }, .. } = msg {
+                       *channel_id == post_funding_chan_id_a
+               } else { false }
+       }).unwrap();
+
+       // The error message uses the funded channel_id so must come after the funding_created
+       assert!(funded_channel_close_pos > funding_created_pos);
 
        check_closed_events(&nodes[0], &close);
        assert_eq!(nodes[0].node.list_channels().len(), 0);