Skip to content

Commit a70d922

Browse files
committed
Use new Channel::update_config method to update base fee in test
1 parent e83e89c commit a70d922

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lightning/src/ln/channel.rs

-3
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,6 @@ pub(crate) const EXPIRE_PREV_CONFIG_TICKS: usize = 5;
500500
// Holder designates channel data owned for the benefice of the user client.
501501
// Counterparty designates channel data owned by the another channel participant entity.
502502
pub(super) struct Channel<Signer: Sign> {
503-
#[cfg(any(test, feature = "_test_utils"))]
504-
pub(crate) config: LegacyChannelConfig,
505-
#[cfg(not(any(test, feature = "_test_utils")))]
506503
config: LegacyChannelConfig,
507504

508505
// Track the previous `ChannelConfig` so that we can continue forwarding HTLCs that were

lightning/src/ln/payment_tests.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use chain::{ChannelMonitorUpdateErr, Confirm, Listen, Watch};
1515
use chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor, LATENCY_GRACE_PERIOD_BLOCKS};
1616
use chain::transaction::OutPoint;
1717
use chain::keysinterface::KeysInterface;
18+
use ln::channel::EXPIRE_PREV_CONFIG_TICKS;
1819
use ln::channelmanager::{BREAKDOWN_TIMEOUT, ChannelManager, ChannelManagerReadArgs, MPP_TIMEOUT_TICKS, PaymentId, PaymentSendFailure};
1920
use ln::features::{InitFeatures, InvoiceFeatures};
2021
use ln::msgs;
@@ -531,9 +532,19 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
531532
// Update the fee on the middle hop to ensure PaymentSent events have the correct (retried) fee
532533
// and not the original fee. We also update node[1]'s relevant config as
533534
// do_claim_payment_along_route expects us to never overpay.
534-
nodes[1].node.channel_state.lock().unwrap().by_id.get_mut(&chan_id_2).unwrap()
535-
.config.options.forwarding_fee_base_msat += 100_000;
536-
new_route.paths[0][0].fee_msat += 100_000;
535+
{
536+
let mut channel_state = nodes[1].node.channel_state.lock().unwrap();
537+
let mut channel = channel_state.by_id.get_mut(&chan_id_2).unwrap();
538+
let mut new_config = channel.config();
539+
new_config.forwarding_fee_base_msat += 100_000;
540+
channel.update_config(&new_config);
541+
new_route.paths[0][0].fee_msat += 100_000;
542+
}
543+
544+
// Force expiration of the channel's previous config.
545+
for _ in 0..EXPIRE_PREV_CONFIG_TICKS {
546+
nodes[1].node.timer_tick_occurred();
547+
}
537548

538549
assert!(nodes[0].node.retry_payment(&new_route, payment_id_1).is_err()); // Shouldn't be allowed to retry a fulfilled payment
539550
nodes[0].node.retry_payment(&new_route, payment_id).unwrap();

0 commit comments

Comments
 (0)