@@ -15026,6 +15026,7 @@ where
15026
15026
mod tests {
15027
15027
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
15028
15028
use bitcoin::secp256k1::ecdh::SharedSecret;
15029
+ use lightning_types::features::ChannelTypeFeatures;
15029
15030
use core::sync::atomic::Ordering;
15030
15031
use crate::events::{Event, HTLCHandlingFailureType, ClosureReason};
15031
15032
use crate::ln::onion_utils::AttributionData;
@@ -15041,7 +15042,7 @@ mod tests {
15041
15042
use crate::util::errors::APIError;
15042
15043
use crate::util::ser::Writeable;
15043
15044
use crate::util::test_utils;
15044
- use crate::util::config::{ChannelConfig, ChannelConfigUpdate, ChannelHandshakeConfigUpdate};
15045
+ use crate::util::config::{ChannelConfig, ChannelConfigUpdate, ChannelHandshakeConfigUpdate, UserConfig };
15045
15046
use crate::sign::EntropySource;
15046
15047
15047
15048
#[test]
@@ -16153,22 +16154,28 @@ mod tests {
16153
16154
}
16154
16155
16155
16156
#[test]
16156
- fn test_anchors_zero_fee_htlc_tx_fallback () {
16157
+ fn test_anchors_zero_fee_htlc_tx_downgrade () {
16157
16158
// Tests that if both nodes support anchors, but the remote node does not want to accept
16158
16159
// anchor channels at the moment, an error it sent to the local node such that it can retry
16159
16160
// the channel without the anchors feature.
16160
- let chanmon_cfgs = create_chanmon_cfgs(2);
16161
- let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
16162
16161
let mut anchors_config = test_default_channel_config();
16163
16162
anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
16164
16163
anchors_config.manually_accept_inbound_channels = true;
16165
- let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(anchors_config.clone()), Some(anchors_config.clone())]);
16164
+
16165
+ do_test_channel_type_downgrade(anchors_config, |features| features.supports_anchors_zero_fee_htlc_tx())
16166
+ }
16167
+
16168
+ fn do_test_channel_type_downgrade<F>(user_cfg: UserConfig, start_type_set: F)
16169
+ where F: Fn(&ChannelTypeFeatures) -> bool {
16170
+ let chanmon_cfgs = create_chanmon_cfgs(2);
16171
+ let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
16172
+ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(user_cfg.clone()), Some(user_cfg.clone())]);
16166
16173
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
16167
16174
let error_message = "Channel force-closed";
16168
16175
16169
16176
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 0, None, None).unwrap();
16170
16177
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
16171
- assert!(open_channel_msg.common_fields.channel_type.as_ref().unwrap().supports_anchors_zero_fee_htlc_tx( ));
16178
+ assert!(start_type_set( open_channel_msg.common_fields.channel_type.as_ref().unwrap()));
16172
16179
16173
16180
nodes[1].node.handle_open_channel(nodes[0].node.get_our_node_id(), &open_channel_msg);
16174
16181
let events = nodes[1].node.get_and_clear_pending_events();
@@ -16183,7 +16190,7 @@ mod tests {
16183
16190
nodes[0].node.handle_error(nodes[1].node.get_our_node_id(), &error_msg);
16184
16191
16185
16192
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
16186
- assert!(!open_channel_msg.common_fields.channel_type.unwrap ().supports_anchors_zero_fee_htlc_tx( ));
16193
+ assert!(!start_type_set( open_channel_msg.common_fields.channel_type.as_ref ().unwrap() ));
16187
16194
16188
16195
// Since nodes[1] should not have accepted the channel, it should
16189
16196
// not have generated any events.
0 commit comments