Merge pull request #3144 from TheBlueMatt/2024-06-message-flags
[rust-lightning] / lightning / src / ln / reload_tests.rs
index 4422af1e8c70c63a81b93ece1aac38e2553d00a0..5f375ec883d7e70678208012833bda7362add137 100644 (file)
@@ -16,7 +16,8 @@ use crate::sign::EntropySource;
 use crate::chain::transaction::OutPoint;
 use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
 use crate::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, PaymentId, RecipientOnionFields};
-use crate::ln::{msgs, ChannelId};
+use crate::ln::msgs;
+use crate::ln::types::ChannelId;
 use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
 use crate::util::test_channel_signer::TestChannelSigner;
 use crate::util::test_utils;
@@ -27,7 +28,6 @@ use crate::util::config::UserConfig;
 use bitcoin::hash_types::BlockHash;
 
 use crate::prelude::*;
-use core::default::Default;
 use crate::sync::Mutex;
 
 use crate::ln::functional_test_utils::*;
@@ -412,7 +412,7 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
        }
 
        let mut nodes_0_read = &nodes_0_serialized[..];
-       if let Err(msgs::DecodeError::InvalidValue) =
+       if let Err(msgs::DecodeError::DangerousValue) =
                <(BlockHash, ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestRouter, &test_utils::TestLogger>)>::read(&mut nodes_0_read, ChannelManagerReadArgs {
                default_config: UserConfig::default(),
                entropy_source: keys_manager,
@@ -628,11 +628,12 @@ fn do_test_data_loss_protect(reconnect_panicing: bool, substantially_old: bool,
                        std::mem::forget(nodes);
                }
        } else {
+               let error_message = "Channel force-closed";
                assert!(!not_stale, "We only care about the stale case when not testing panicking");
 
-               nodes[0].node.force_close_without_broadcasting_txn(&chan.2, &nodes[1].node.get_our_node_id()).unwrap();
+               nodes[0].node.force_close_without_broadcasting_txn(&chan.2, &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap();
                check_added_monitors!(nodes[0], 1);
-               check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed, [nodes[1].node.get_our_node_id()], 1000000);
+               check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }, [nodes[1].node.get_our_node_id()], 1000000);
                {
                        let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
                        assert_eq!(node_txn.len(), 0);
@@ -642,8 +643,8 @@ fn do_test_data_loss_protect(reconnect_panicing: bool, substantially_old: bool,
                        if let MessageSendEvent::BroadcastChannelUpdate { .. } = msg {
                        } else if let MessageSendEvent::HandleError { ref action, .. } = msg {
                                match action {
-                                       &ErrorAction::DisconnectPeer { ref msg } => {
-                                               assert_eq!(msg.as_ref().unwrap().data, "Channel force-closed");
+                                       &ErrorAction::SendErrorMessage { ref msg } => {
+                                               assert_eq!(&msg.data, "Channel force-closed");
                                        },
                                        _ => panic!("Unexpected event!"),
                                }
@@ -1025,13 +1026,14 @@ fn do_forwarded_payment_no_manager_persistence(use_cs_commitment: bool, claim_ht
        assert!(nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap().is_empty());
 
        let _ = nodes[2].node.get_and_clear_pending_msg_events();
+       let error_message = "Channel force-closed";
 
-       nodes[2].node.force_close_broadcasting_latest_txn(&chan_id_2, &nodes[1].node.get_our_node_id()).unwrap();
+       nodes[2].node.force_close_broadcasting_latest_txn(&chan_id_2, &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap();
        let cs_commitment_tx = nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
        assert_eq!(cs_commitment_tx.len(), if claim_htlc { 2 } else { 1 });
 
        check_added_monitors!(nodes[2], 1);
-       check_closed_event!(nodes[2], 1, ClosureReason::HolderForceClosed, [nodes[1].node.get_our_node_id()], 100000);
+       check_closed_event!(nodes[2], 1, ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(true) }, [nodes[1].node.get_our_node_id()], 100000);
        check_closed_broadcast!(nodes[2], true);
 
        let chan_0_monitor_serialized = get_monitor!(nodes[1], chan_id_1).encode();