Swap `UserConfig::default()` for `test_default_channel_config`
authorMatt Corallo <git@bluematt.me>
Wed, 1 May 2024 21:56:04 +0000 (21:56 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 2 May 2024 15:39:03 +0000 (15:39 +0000)
As LDK changes, `UserConfig::default()` may imply marginally
different behavior, whereas `test_default_channel_config` is
intended to tweak defaults to provide a stable behavior for test
contexts.

This commit changes a few uses of `UserConfig::default()` to
`test_default_channel_config` in cases that will fail over the
coming commits due to dust changes.

lightning/src/ln/functional_tests.rs
lightning/src/ln/monitor_tests.rs
lightning/src/ln/onion_route_tests.rs

index 465d6288d9d3e764662edb2276d7bb5bef477cb3..34ca9a7101f41e44a6f4445f78211eba46486468 100644 (file)
@@ -2433,11 +2433,11 @@ fn channel_monitor_network_test() {
 #[test]
 fn test_justice_tx_htlc_timeout() {
        // Test justice txn built on revoked HTLC-Timeout tx, against both sides
-       let mut alice_config = UserConfig::default();
+       let mut alice_config = test_default_channel_config();
        alice_config.channel_handshake_config.announced_channel = true;
        alice_config.channel_handshake_limits.force_announced_channel_preference = false;
        alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5;
-       let mut bob_config = UserConfig::default();
+       let mut bob_config = test_default_channel_config();
        bob_config.channel_handshake_config.announced_channel = true;
        bob_config.channel_handshake_limits.force_announced_channel_preference = false;
        bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3;
@@ -2496,11 +2496,11 @@ fn test_justice_tx_htlc_timeout() {
 #[test]
 fn test_justice_tx_htlc_success() {
        // Test justice txn built on revoked HTLC-Success tx, against both sides
-       let mut alice_config = UserConfig::default();
+       let mut alice_config = test_default_channel_config();
        alice_config.channel_handshake_config.announced_channel = true;
        alice_config.channel_handshake_limits.force_announced_channel_preference = false;
        alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5;
-       let mut bob_config = UserConfig::default();
+       let mut bob_config = test_default_channel_config();
        bob_config.channel_handshake_config.announced_channel = true;
        bob_config.channel_handshake_limits.force_announced_channel_preference = false;
        bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3;
index d5f28c23b4e6271510f78a741e038deeb3e05c3a..83d22c4deea35583b54863367c9e75252aae97dc 100644 (file)
@@ -18,7 +18,6 @@ use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureR
 use crate::ln::{channel, ChannelId};
 use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, PaymentId, RecipientOnionFields};
 use crate::ln::msgs::ChannelMessageHandler;
-use crate::util::config::UserConfig;
 use crate::crypto::utils::sign;
 use crate::util::ser::Writeable;
 use crate::util::scid_utils::block_from_scid;
@@ -2249,7 +2248,7 @@ fn test_yield_anchors_events() {
        // emitted by LDK, such that the consumer can attach fees to the zero fee HTLC transactions.
        let mut chanmon_cfgs = create_chanmon_cfgs(2);
        let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
-       let mut anchors_config = UserConfig::default();
+       let mut anchors_config = test_default_channel_config();
        anchors_config.channel_handshake_config.announced_channel = true;
        anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
        anchors_config.manually_accept_inbound_channels = true;
@@ -2400,7 +2399,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
        let bob_persister;
        let bob_chain_monitor;
 
-       let mut anchors_config = UserConfig::default();
+       let mut anchors_config = test_default_channel_config();
        anchors_config.channel_handshake_config.announced_channel = true;
        anchors_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
        anchors_config.manually_accept_inbound_channels = true;
index aeb175bc62660b6091c0a71a3960e4dc6ca1bc5e..8b21139667de3b02c9f27bb688cff2f8e90ba65b 100644 (file)
@@ -21,6 +21,7 @@ use crate::ln::onion_utils;
 use crate::routing::gossip::{NetworkUpdate, RoutingFees};
 use crate::routing::router::{get_route, PaymentParameters, Route, RouteParameters, RouteHint, RouteHintHop};
 use crate::ln::features::{InitFeatures, Bolt11InvoiceFeatures};
+use crate::ln::functional_test_utils::test_default_channel_config;
 use crate::ln::msgs;
 use crate::ln::msgs::{ChannelMessageHandler, ChannelUpdate, OutboundTrampolinePayload};
 use crate::ln::wire::Encode;
@@ -328,7 +329,7 @@ fn test_onion_failure() {
        // to 2000, which is above the default value of 1000 set in create_node_chanmgrs.
        // This exposed a previous bug because we were using the wrong value all the way down in
        // Channel::get_counterparty_htlc_minimum_msat().
-       let mut node_2_cfg: UserConfig = Default::default();
+       let mut node_2_cfg: UserConfig = test_default_channel_config();
        node_2_cfg.channel_handshake_config.our_htlc_minimum_msat = 2000;
        node_2_cfg.channel_handshake_config.announced_channel = true;
        node_2_cfg.channel_handshake_limits.force_announced_channel_preference = false;