Skip to content

Commit d2647e0

Browse files
author
Antoine Riard
committed
Pass LocalFeatures flag to channel creation test utilities
We may want more granularity on the set of features activated at a given time, specially with new 1.1 spec features
1 parent 4769b94 commit d2647e0

File tree

3 files changed

+136
-136
lines changed

3 files changed

+136
-136
lines changed

src/ln/chanmon_update_fail_tests.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use ln::channelmanager::{RAACommitmentOrder, PaymentPreimage, PaymentHash};
77
use ln::channelmonitor::ChannelMonitorUpdateErr;
88
use ln::msgs;
9-
use ln::msgs::ChannelMessageHandler;
9+
use ln::msgs::{ChannelMessageHandler, LocalFeatures};
1010
use util::events::{Event, EventsProvider, MessageSendEvent, MessageSendEventsProvider};
1111
use util::errors::APIError;
1212

@@ -19,7 +19,7 @@ use ln::functional_test_utils::*;
1919
fn test_simple_monitor_permanent_update_fail() {
2020
// Test that we handle a simple permanent monitor update failure
2121
let mut nodes = create_network(2);
22-
create_announced_chan_between_nodes(&nodes, 0, 1);
22+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
2323

2424
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
2525
let (_, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
@@ -49,7 +49,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
4949
// Test that we can recover from a simple temporary monitor update failure optionally with
5050
// a disconnect in between
5151
let mut nodes = create_network(2);
52-
create_announced_chan_between_nodes(&nodes, 0, 1);
52+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
5353

5454
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
5555
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) {
148148
// through, swapping message ordering based on disconnect_count & 8 and optionally
149149
// disconnect/reconnecting based on disconnect_count.
150150
let mut nodes = create_network(2);
151-
create_announced_chan_between_nodes(&nodes, 0, 1);
151+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
152152

153153
let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
154154

@@ -474,7 +474,7 @@ fn test_monitor_temporary_update_fail_c() {
474474
fn test_monitor_update_fail_cs() {
475475
// Tests handling of a monitor update failure when processing an incoming commitment_signed
476476
let mut nodes = create_network(2);
477-
create_announced_chan_between_nodes(&nodes, 0, 1);
477+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
478478

479479
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
480480
let (payment_preimage, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
@@ -553,7 +553,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
553553
// test_restore_channel_monitor() is required. Backported from
554554
// chanmon_fail_consistency fuzz tests.
555555
let mut nodes = create_network(2);
556-
create_announced_chan_between_nodes(&nodes, 0, 1);
556+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
557557

558558
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
559559
let (payment_preimage_1, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
@@ -595,7 +595,7 @@ fn test_monitor_update_raa_while_paused() {
595595
// Tests handling of an RAA while monitor updating has already been marked failed.
596596
// Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
597597
let mut nodes = create_network(2);
598-
create_announced_chan_between_nodes(&nodes, 0, 1);
598+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
599599

600600
send_payment(&nodes[0], &[&nodes[1]], 5000000);
601601

@@ -662,8 +662,8 @@ fn test_monitor_update_raa_while_paused() {
662662
fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
663663
// Tests handling of a monitor update failure when processing an incoming RAA
664664
let mut nodes = create_network(3);
665-
create_announced_chan_between_nodes(&nodes, 0, 1);
666-
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2);
665+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
666+
let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
667667

668668
// Rebalance a bit so that we can send backwards from 2 to 1.
669669
send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
@@ -915,8 +915,8 @@ fn test_monitor_update_fail_reestablish() {
915915
// channel_reestablish generating a monitor update (which comes from freeing holding cell
916916
// HTLCs).
917917
let mut nodes = create_network(3);
918-
create_announced_chan_between_nodes(&nodes, 0, 1);
919-
create_announced_chan_between_nodes(&nodes, 1, 2);
918+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
919+
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
920920

921921
let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
922922

@@ -993,7 +993,7 @@ fn raa_no_response_awaiting_raa_state() {
993993
// in question (assuming it intends to respond with a CS after monitor updating is restored).
994994
// Backported from chanmon_fail_consistency fuzz tests as this used to be broken.
995995
let mut nodes = create_network(2);
996-
create_announced_chan_between_nodes(&nodes, 0, 1);
996+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
997997

998998
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(), None, &Vec::new(), 1000000, TEST_FINAL_CLTV).unwrap();
999999
let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
@@ -1106,7 +1106,7 @@ fn claim_while_disconnected_monitor_update_fail() {
11061106
// code introduced a regression in this test (specifically, this caught a removal of the
11071107
// channel_reestablish handling ensuring the order was sensical given the messages used).
11081108
let mut nodes = create_network(2);
1109-
create_announced_chan_between_nodes(&nodes, 0, 1);
1109+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
11101110

11111111
// Forward a payment for B to claim
11121112
let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
@@ -1221,7 +1221,7 @@ fn monitor_failed_no_reestablish_response() {
12211221
// Backported from chanmon_fail_consistency fuzz tests as it caught a long-standing
12221222
// debug_assert!() failure in channel_reestablish handling.
12231223
let mut nodes = create_network(2);
1224-
create_announced_chan_between_nodes(&nodes, 0, 1);
1224+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
12251225

12261226
// Route the payment and deliver the initial commitment_signed (with a monitor update failure
12271227
// on receipt).
@@ -1287,7 +1287,7 @@ fn first_message_on_recv_ordering() {
12871287
// payment applied).
12881288
// Backported from chanmon_fail_consistency fuzz tests as it caught a bug here.
12891289
let mut nodes = create_network(2);
1290-
create_announced_chan_between_nodes(&nodes, 0, 1);
1290+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
12911291

12921292
// Route the first payment outbound, holding the last RAA for B until we are set up so that we
12931293
// can deliver it and fail the monitor update.
@@ -1372,8 +1372,8 @@ fn test_monitor_update_fail_claim() {
13721372
// payment from B to A fail due to the paused channel. Finally, we restore the channel monitor
13731373
// updating and claim the payment on B.
13741374
let mut nodes = create_network(3);
1375-
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
1376-
create_announced_chan_between_nodes(&nodes, 1, 2);
1375+
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
1376+
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
13771377

13781378
// Rebalance a bit so that we can send backwards from 3 to 2.
13791379
send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
@@ -1442,8 +1442,8 @@ fn test_monitor_update_on_pending_forwards() {
14421442
// The payment from A to C will be failed by C and pending a back-fail to A, while the payment
14431443
// from C to A will be pending a forward to A.
14441444
let mut nodes = create_network(3);
1445-
create_announced_chan_between_nodes(&nodes, 0, 1);
1446-
create_announced_chan_between_nodes(&nodes, 1, 2);
1445+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
1446+
create_announced_chan_between_nodes(&nodes, 1, 2, LocalFeatures::new(), LocalFeatures::new());
14471447

14481448
// Rebalance a bit so that we can send backwards from 3 to 1.
14491449
send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000);
@@ -1506,7 +1506,7 @@ fn monitor_update_claim_fail_no_response() {
15061506
// Backported from chanmon_fail_consistency fuzz tests as an unmerged version of the handling
15071507
// code was broken.
15081508
let mut nodes = create_network(2);
1509-
create_announced_chan_between_nodes(&nodes, 0, 1);
1509+
create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
15101510

15111511
// Forward a payment for B to claim
15121512
let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);

src/ln/functional_test_utils.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ impl Drop for Node {
9292
}
9393
}
9494

95-
pub fn create_chan_between_nodes(node_a: &Node, node_b: &Node) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
96-
create_chan_between_nodes_with_value(node_a, node_b, 100000, 10001)
95+
pub fn create_chan_between_nodes(node_a: &Node, node_b: &Node, a_flags: LocalFeatures, b_flags: LocalFeatures) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
96+
create_chan_between_nodes_with_value(node_a, node_b, 100000, 10001, a_flags, b_flags)
9797
}
9898

99-
pub fn create_chan_between_nodes_with_value(node_a: &Node, node_b: &Node, channel_value: u64, push_msat: u64) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
100-
let (funding_locked, channel_id, tx) = create_chan_between_nodes_with_value_a(node_a, node_b, channel_value, push_msat);
99+
pub fn create_chan_between_nodes_with_value(node_a: &Node, node_b: &Node, channel_value: u64, push_msat: u64, a_flags: LocalFeatures, b_flags: LocalFeatures) -> (msgs::ChannelAnnouncement, msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
100+
let (funding_locked, channel_id, tx) = create_chan_between_nodes_with_value_a(node_a, node_b, channel_value, push_msat, a_flags, b_flags);
101101
let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(node_a, node_b, &funding_locked);
102102
(announcement, as_update, bs_update, channel_id, tx)
103103
}
@@ -172,10 +172,10 @@ macro_rules! get_feerate {
172172
}
173173

174174

175-
pub fn create_chan_between_nodes_with_value_init(node_a: &Node, node_b: &Node, channel_value: u64, push_msat: u64) -> Transaction {
175+
pub fn create_chan_between_nodes_with_value_init(node_a: &Node, node_b: &Node, channel_value: u64, push_msat: u64, a_flags: LocalFeatures, b_flags: LocalFeatures) -> Transaction {
176176
node_a.node.create_channel(node_b.node.get_our_node_id(), channel_value, push_msat, 42).unwrap();
177-
node_b.node.handle_open_channel(&node_a.node.get_our_node_id(), LocalFeatures::new(), &get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id())).unwrap();
178-
node_a.node.handle_accept_channel(&node_b.node.get_our_node_id(), LocalFeatures::new(), &get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id())).unwrap();
177+
node_b.node.handle_open_channel(&node_a.node.get_our_node_id(), a_flags, &get_event_msg!(node_a, MessageSendEvent::SendOpenChannel, node_b.node.get_our_node_id())).unwrap();
178+
node_a.node.handle_accept_channel(&node_b.node.get_our_node_id(), b_flags, &get_event_msg!(node_b, MessageSendEvent::SendAcceptChannel, node_a.node.get_our_node_id())).unwrap();
179179

180180
let chan_id = *node_a.network_chan_count.borrow();
181181
let tx;
@@ -256,8 +256,8 @@ pub fn create_chan_between_nodes_with_value_confirm(node_a: &Node, node_b: &Node
256256
}), channel_id)
257257
}
258258

259-
pub fn create_chan_between_nodes_with_value_a(node_a: &Node, node_b: &Node, channel_value: u64, push_msat: u64) -> ((msgs::FundingLocked, msgs::AnnouncementSignatures), [u8; 32], Transaction) {
260-
let tx = create_chan_between_nodes_with_value_init(node_a, node_b, channel_value, push_msat);
259+
pub fn create_chan_between_nodes_with_value_a(node_a: &Node, node_b: &Node, channel_value: u64, push_msat: u64, a_flags: LocalFeatures, b_flags: LocalFeatures) -> ((msgs::FundingLocked, msgs::AnnouncementSignatures), [u8; 32], Transaction) {
260+
let tx = create_chan_between_nodes_with_value_init(node_a, node_b, channel_value, push_msat, a_flags, b_flags);
261261
let (msgs, chan_id) = create_chan_between_nodes_with_value_confirm(node_a, node_b, &tx);
262262
(msgs, chan_id, tx)
263263
}
@@ -294,12 +294,12 @@ pub fn create_chan_between_nodes_with_value_b(node_a: &Node, node_b: &Node, as_f
294294
((*announcement).clone(), (*as_update).clone(), (*bs_update).clone())
295295
}
296296

297-
pub fn create_announced_chan_between_nodes(nodes: &Vec<Node>, a: usize, b: usize) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
298-
create_announced_chan_between_nodes_with_value(nodes, a, b, 100000, 10001)
297+
pub fn create_announced_chan_between_nodes(nodes: &Vec<Node>, a: usize, b: usize, a_flags: LocalFeatures, b_flags: LocalFeatures) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
298+
create_announced_chan_between_nodes_with_value(nodes, a, b, 100000, 10001, a_flags, b_flags)
299299
}
300300

301-
pub fn create_announced_chan_between_nodes_with_value(nodes: &Vec<Node>, a: usize, b: usize, channel_value: u64, push_msat: u64) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
302-
let chan_announcement = create_chan_between_nodes_with_value(&nodes[a], &nodes[b], channel_value, push_msat);
301+
pub fn create_announced_chan_between_nodes_with_value(nodes: &Vec<Node>, a: usize, b: usize, channel_value: u64, push_msat: u64, a_flags: LocalFeatures, b_flags: LocalFeatures) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, [u8; 32], Transaction) {
302+
let chan_announcement = create_chan_between_nodes_with_value(&nodes[a], &nodes[b], channel_value, push_msat, a_flags, b_flags);
303303
for node in nodes {
304304
assert!(node.router.handle_channel_announcement(&chan_announcement.0).unwrap());
305305
node.router.handle_channel_update(&chan_announcement.1).unwrap();

0 commit comments

Comments
 (0)