Implement Flat Features
[rust-lightning] / lightning / src / ln / chanmon_update_fail_tests.rs
index 8849c2ed5565bbe48896ef58f4e91871875a7e90..89d1786247c5117e3035c9094964abdba93010f9 100644 (file)
@@ -6,7 +6,7 @@
 use ln::channelmanager::{RAACommitmentOrder, PaymentPreimage, PaymentHash};
 use ln::channelmonitor::ChannelMonitorUpdateErr;
 use ln::msgs;
-use ln::msgs::{ChannelMessageHandler, LocalFeatures, RoutingMessageHandler, ErrorAction};
+use ln::msgs::{ChannelMessageHandler, ErrorAction, Features, FeatureContextInit, RoutingMessageHandler};
 use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider};
 use util::errors::APIError;
 
@@ -19,7 +19,7 @@ use ln::functional_test_utils::*;
 fn test_simple_monitor_permanent_update_fail() {
        // Test that we handle a simple permanent monitor update failure
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
        let (_, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
@@ -49,7 +49,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
        // Test that we can recover from a simple temporary monitor update failure optionally with
        // a disconnect in between
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
        let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
@@ -148,7 +148,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
        //   through, swapping message ordering based on disconnect_count & 8 and optionally
        //   disconnect/reconnecting based on disconnect_count.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
@@ -474,7 +474,7 @@ fn test_monitor_temporary_update_fail_c() {
 fn test_monitor_update_fail_cs() {
        // Tests handling of a monitor update failure when processing an incoming commitment_signed
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
        let (payment_preimage, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
@@ -553,7 +553,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
        // test_restore_channel_monitor() is required. Backported from
        // chanmon_fail_consistency fuzz tests.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
        let (payment_preimage_1, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
@@ -595,7 +595,7 @@ fn test_monitor_update_raa_while_paused() {
        // Tests handling of an RAA while monitor updating has already been marked failed.
        // Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        send_payment(&nodes[0], &[&nodes[1]], 5000000, 5_000_000);
 
@@ -662,8 +662,8 @@ fn test_monitor_update_raa_while_paused() {
 fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
        // Tests handling of a monitor update failure when processing an incoming RAA
        let mut nodes = create_network(3, &[None, None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
-       let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
+       let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Rebalance a bit so that we can send backwards from 2 to 1.
        send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
@@ -915,8 +915,8 @@ fn test_monitor_update_fail_reestablish() {
        // channel_reestablish generating a monitor update (which comes from freeing holding cell
        // HTLCs).
        let mut nodes = create_network(3, &[None, None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
-       create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
+       create_announced_chan_between_nodes(&nodes, 1, 2, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
 
@@ -993,7 +993,7 @@ fn raa_no_response_awaiting_raa_state() {
        // in question (assuming it intends to respond with a CS after monitor updating is restored).
        // Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
        let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
@@ -1106,7 +1106,7 @@ fn claim_while_disconnected_monitor_update_fail() {
        // code introduced a regression in this test (specifically, this caught a removal of the
        // channel_reestablish handling ensuring the order was sensical given the messages used).
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Forward a payment for B to claim
        let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
@@ -1221,7 +1221,7 @@ fn monitor_failed_no_reestablish_response() {
        // Backported from chanmon_fail_consistency fuzz tests as it caught a long-standing
        // debug_assert!() failure in channel_reestablish handling.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Route the payment and deliver the initial commitment_signed (with a monitor update failure
        // on receipt).
@@ -1287,7 +1287,7 @@ fn first_message_on_recv_ordering() {
        // payment applied).
        // Backported from chanmon_fail_consistency fuzz tests as it caught a bug here.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Route the first payment outbound, holding the last RAA for B until we are set up so that we
        // can deliver it and fail the monitor update.
@@ -1372,8 +1372,8 @@ fn test_monitor_update_fail_claim() {
        // payment from B to A fail due to the paused channel. Finally, we restore the channel monitor
        // updating and claim the payment on B.
        let mut nodes = create_network(3, &[None, None, None]);
-       let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
-       create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
+       let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
+       create_announced_chan_between_nodes(&nodes, 1, 2, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Rebalance a bit so that we can send backwards from 3 to 2.
        send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
@@ -1445,8 +1445,8 @@ fn test_monitor_update_on_pending_forwards() {
        // The payment from A to C will be failed by C and pending a back-fail to A, while the payment
        // from C to A will be pending a forward to A.
        let mut nodes = create_network(3, &[None, None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
-       create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
+       create_announced_chan_between_nodes(&nodes, 1, 2, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Rebalance a bit so that we can send backwards from 3 to 1.
        send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
@@ -1510,7 +1510,7 @@ fn monitor_update_claim_fail_no_response() {
        // Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
        // code was broken.
        let mut nodes = create_network(2, &[None, None]);
-       create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
+       create_announced_chan_between_nodes(&nodes, 0, 1, Features::<FeatureContextInit>::new(), Features::<FeatureContextInit>::new());
 
        // Forward a payment for B to claim
        let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
@@ -1571,8 +1571,8 @@ fn do_during_funding_monitor_fail(fail_on_generate: bool, restore_between_fails:
        let mut nodes = create_network(2, &[None, None]);
 
        nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 43).unwrap();
-       nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), LocalFeatures::new(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
-       nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), LocalFeatures::new(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
+       nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), Features::<FeatureContextInit>::new(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id()));
+       nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), Features::<FeatureContextInit>::new(), &get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id()));
 
        let (temporary_channel_id, funding_tx, funding_output) = create_funding_transaction(&nodes[0], 100000, 43);