Skip to content

Commit

Permalink
Use new Channel::update_config method to update base fee in test
Browse files Browse the repository at this point in the history
  • Loading branch information
wpaulino committed Jun 16, 2022
1 parent bb0901a commit 4d0bb1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 0 additions & 3 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,6 @@ pub(crate) const MIN_AFFORDABLE_HTLC_COUNT: usize = 4;
// Holder designates channel data owned for the benefice of the user client.
// Counterparty designates channel data owned by the another channel participant entity.
pub(super) struct Channel<Signer: Sign> {
#[cfg(any(test, feature = "_test_utils"))]
pub(crate) config: LegacyChannelConfig,
#[cfg(not(any(test, feature = "_test_utils")))]
config: LegacyChannelConfig,

// Track the previous `ChannelConfig` so that we can continue forwarding HTLCs that were
Expand Down
11 changes: 8 additions & 3 deletions lightning/src/ln/payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,14 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) {
// Update the fee on the middle hop to ensure PaymentSent events have the correct (retried) fee
// and not the original fee. We also update node[1]'s relevant config as
// do_claim_payment_along_route expects us to never overpay.
nodes[1].node.channel_state.lock().unwrap().by_id.get_mut(&chan_id_2).unwrap()
.config.options.forwarding_fee_base_msat += 100_000;
new_route.paths[0][0].fee_msat += 100_000;
{
let mut channel_state = nodes[1].node.channel_state.lock().unwrap();
let mut channel = channel_state.by_id.get_mut(&chan_id_2).unwrap();
let mut new_config = channel.get_config();
new_config.forwarding_fee_base_msat += 100_000;
channel.update_config(&new_config, false);
new_route.paths[0][0].fee_msat += 100_000;
}

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

0 comments on commit 4d0bb1b

Please sign in to comment.