Never block a thread on the `PeerManager` event handling lock
[rust-lightning] / lightning / src / ln / functional_test_utils.rs
index 96b9dde5aa6fbc8a7379418b287bf89664889665..637c05ff2e447ce5202d59ad70a16dcdeb0a547b 100644 (file)
@@ -10,7 +10,8 @@
 //! A bunch of useful utilities for building networks of nodes and exchanging messages between
 //! nodes for functional tests.
 
-use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch, keysinterface::EntropySource};
+use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch};
+use crate::sign::EntropySource;
 use crate::chain::channelmonitor::ChannelMonitor;
 use crate::chain::transaction::OutPoint;
 use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, PaymentFailureReason};
@@ -723,6 +724,39 @@ pub fn remove_first_msg_event_to_node(msg_node_id: &PublicKey, msg_events: &mut
                MessageSendEvent::SendGossipTimestampFilter { node_id, .. } => {
                        node_id == msg_node_id
                },
+               MessageSendEvent::SendAcceptChannelV2 { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendOpenChannelV2 { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxAddInput { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxAddOutput { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxRemoveInput { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxRemoveOutput { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxComplete { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxSignatures { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxInitRbf { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxAckRbf { node_id, .. } => {
+                       node_id == msg_node_id
+               },
+               MessageSendEvent::SendTxAbort { node_id, .. } => {
+                       node_id == msg_node_id
+               },
        }});
        if ev_index.is_some() {
                msg_events.remove(ev_index.unwrap())
@@ -1723,7 +1757,7 @@ macro_rules! get_route {
 macro_rules! get_route_and_payment_hash {
        ($send_node: expr, $recv_node: expr, $recv_value: expr) => {{
                let payment_params = $crate::routing::router::PaymentParameters::from_node_id($recv_node.node.get_our_node_id(), TEST_FINAL_CLTV)
-                       .with_features($recv_node.node.invoice_features());
+                       .with_bolt11_features($recv_node.node.invoice_features()).unwrap();
                $crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value)
        }};
        ($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr) => {{
@@ -2272,7 +2306,7 @@ pub const TEST_FINAL_CLTV: u32 = 70;
 
 pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash, PaymentSecret) {
        let payment_params = PaymentParameters::from_node_id(expected_route.last().unwrap().node.get_our_node_id(), TEST_FINAL_CLTV)
-               .with_features(expected_route.last().unwrap().node.invoice_features());
+               .with_bolt11_features(expected_route.last().unwrap().node.invoice_features()).unwrap();
        let route = get_route(origin_node, &payment_params, recv_value).unwrap();
        assert_eq!(route.paths.len(), 1);
        assert_eq!(route.paths[0].hops.len(), expected_route.len());
@@ -2286,7 +2320,7 @@ pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route:
 
 pub fn route_over_limit<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64)  {
        let payment_params = PaymentParameters::from_node_id(expected_route.last().unwrap().node.get_our_node_id(), TEST_FINAL_CLTV)
-               .with_features(expected_route.last().unwrap().node.invoice_features());
+               .with_bolt11_features(expected_route.last().unwrap().node.invoice_features()).unwrap();
        let network_graph = origin_node.network_graph.read_only();
        let scorer = test_utils::TestScorer::new();
        let seed = [0u8; 32];