Skip to content

Commit 63d66f8

Browse files
committed
Move channel reserve tests out of functional_tests.rs into a new file
`functional_tests.rs` has gotten incredibly huge over the years, so here we move some channel reserve tests into a new file.
1 parent 319048b commit 63d66f8

File tree

4 files changed

+518
-498
lines changed

4 files changed

+518
-498
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ use crate::chain::transaction::OutPoint;
1616
use crate::events::{ClaimedHTLC, ClosureReason, Event, HTLCHandlingFailureType, PaidBolt12Invoice, PathFailure, PaymentFailureReason, PaymentPurpose};
1717
use crate::events::bump_transaction::{BumpTransactionEvent, BumpTransactionEventHandler, Wallet, WalletSource};
1818
use crate::ln::types::ChannelId;
19+
use crate::types::features::ChannelTypeFeatures;
1920
use crate::types::payment::{PaymentPreimage, PaymentHash, PaymentSecret};
21+
use crate::ln::chan_utils::{commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC};
2022
use crate::ln::channelmanager::{AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, RecipientOnionFields, PaymentId, MIN_CLTV_EXPIRY_DELTA};
2123
use crate::types::features::InitFeatures;
2224
use crate::ln::msgs;
@@ -1104,6 +1106,10 @@ macro_rules! unwrap_send_err {
11041106
}
11051107
}
11061108

1109+
pub fn commit_tx_fee_msat(feerate: u32, num_htlcs: u64, channel_type_features: &ChannelTypeFeatures) -> u64 {
1110+
(commitment_tx_base_weight(channel_type_features) + num_htlcs * COMMITMENT_TX_WEIGHT_PER_HTLC) * feerate as u64 / 1000 * 1000
1111+
}
1112+
11071113
/// Check whether N channel monitor(s) have been added.
11081114
pub fn check_added_monitors<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &H, count: usize) {
11091115
if let Some(chain_monitor) = node.chain_monitor() {

0 commit comments

Comments
 (0)