Skip to content

Commit 217a5b0

Browse files
authored
Merge pull request #3783 from TheBlueMatt/2025-05-rustfmt-tests-2
Run rustfmt on `chain/transaction`, `chain/chaininterface`, `max_payment_path_len_tests`, and `chanmon_update_fail_tests`
2 parents 7e6ca67 + b9d0d60 commit 217a5b0

File tree

4 files changed

+1894
-1114
lines changed

4 files changed

+1894
-1114
lines changed

lightning/src/chain/chaininterface.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(rustfmt, rustfmt_skip)]
2-
31
// This file is Copyright its original authors, visible in version control
42
// history.
53
//
@@ -189,25 +187,29 @@ pub const FEERATE_FLOOR_SATS_PER_KW: u32 = 253;
189187
///
190188
/// Note that this does *not* implement [`FeeEstimator`] to make it harder to accidentally mix the
191189
/// two.
192-
pub(crate) struct LowerBoundedFeeEstimator<F: Deref>(pub F) where F::Target: FeeEstimator;
193-
194-
impl<F: Deref> LowerBoundedFeeEstimator<F> where F::Target: FeeEstimator {
190+
pub(crate) struct LowerBoundedFeeEstimator<F: Deref>(pub F)
191+
where
192+
F::Target: FeeEstimator;
193+
194+
impl<F: Deref> LowerBoundedFeeEstimator<F>
195+
where
196+
F::Target: FeeEstimator,
197+
{
195198
/// Creates a new `LowerBoundedFeeEstimator` which wraps the provided fee_estimator
196199
pub fn new(fee_estimator: F) -> Self {
197200
LowerBoundedFeeEstimator(fee_estimator)
198201
}
199202

200203
pub fn bounded_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32 {
201-
cmp::max(
202-
self.0.get_est_sat_per_1000_weight(confirmation_target),
203-
FEERATE_FLOOR_SATS_PER_KW,
204-
)
204+
cmp::max(self.0.get_est_sat_per_1000_weight(confirmation_target), FEERATE_FLOOR_SATS_PER_KW)
205205
}
206206
}
207207

208208
#[cfg(test)]
209209
mod tests {
210-
use super::{FEERATE_FLOOR_SATS_PER_KW, LowerBoundedFeeEstimator, ConfirmationTarget, FeeEstimator};
210+
use super::{
211+
ConfirmationTarget, FeeEstimator, LowerBoundedFeeEstimator, FEERATE_FLOOR_SATS_PER_KW,
212+
};
211213

212214
struct TestFeeEstimator {
213215
sat_per_kw: u32,
@@ -225,7 +227,10 @@ mod tests {
225227
let test_fee_estimator = &TestFeeEstimator { sat_per_kw };
226228
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
227229

228-
assert_eq!(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::AnchorChannelFee), FEERATE_FLOOR_SATS_PER_KW);
230+
assert_eq!(
231+
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::AnchorChannelFee),
232+
FEERATE_FLOOR_SATS_PER_KW
233+
);
229234
}
230235

231236
#[test]
@@ -234,6 +239,9 @@ mod tests {
234239
let test_fee_estimator = &TestFeeEstimator { sat_per_kw };
235240
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
236241

237-
assert_eq!(fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::AnchorChannelFee), sat_per_kw);
242+
assert_eq!(
243+
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::AnchorChannelFee),
244+
sat_per_kw
245+
);
238246
}
239247
}

lightning/src/chain/transaction.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(rustfmt, rustfmt_skip)]
2-
31
// This file is Copyright its original authors, visible in version control
42
// history.
53
//
@@ -63,10 +61,7 @@ impl OutPoint {
6361
/// This is not exported to bindings users as the same type is used universally in the C bindings
6462
/// for all outpoints
6563
pub fn into_bitcoin_outpoint(self) -> BitcoinOutPoint {
66-
BitcoinOutPoint {
67-
txid: self.txid,
68-
vout: self.index as u32,
69-
}
64+
BitcoinOutPoint { txid: self.txid, vout: self.index as u32 }
7065
}
7166
}
7267

@@ -92,20 +87,24 @@ mod tests {
9287
use crate::chain::transaction::OutPoint;
9388
use crate::ln::types::ChannelId;
9489

95-
use bitcoin::transaction::Transaction;
9690
use bitcoin::consensus::encode;
9791
use bitcoin::hex::FromHex;
92+
use bitcoin::transaction::Transaction;
9893

9994
#[test]
10095
fn test_channel_id_calculation() {
101-
let tx: Transaction = encode::deserialize(&<Vec<u8>>::from_hex("020000000001010e0adef48412e4361325ac1c6e36411299ab09d4f083b9d8ddb55fbc06e1b0c00000000000feffffff0220a1070000000000220020f81d95e040bd0a493e38bae27bff52fe2bb58b93b293eb579c01c31b05c5af1dc072cfee54a3000016001434b1d6211af5551905dc2642d05f5b04d25a8fe80247304402207f570e3f0de50546aad25a872e3df059d277e776dda4269fa0d2cc8c2ee6ec9a022054e7fae5ca94d47534c86705857c24ceea3ad51c69dd6051c5850304880fc43a012103cb11a1bacc223d98d91f1946c6752e358a5eb1a1c983b3e6fb15378f453b76bd00000000").unwrap()[..]).unwrap();
102-
assert_eq!(&ChannelId::v1_from_funding_outpoint(OutPoint {
103-
txid: tx.compute_txid(),
104-
index: 0
105-
}).0[..], &<Vec<u8>>::from_hex("3e88dd7165faf7be58b3c5bb2c9c452aebef682807ea57080f62e6f6e113c25e").unwrap()[..]);
106-
assert_eq!(&ChannelId::v1_from_funding_outpoint(OutPoint {
107-
txid: tx.compute_txid(),
108-
index: 1
109-
}).0[..], &<Vec<u8>>::from_hex("3e88dd7165faf7be58b3c5bb2c9c452aebef682807ea57080f62e6f6e113c25f").unwrap()[..]);
96+
let tx_hex = "020000000001010e0adef48412e4361325ac1c6e36411299ab09d4f083b9d8ddb55fbc06e1b0c00000000000feffffff0220a1070000000000220020f81d95e040bd0a493e38bae27bff52fe2bb58b93b293eb579c01c31b05c5af1dc072cfee54a3000016001434b1d6211af5551905dc2642d05f5b04d25a8fe80247304402207f570e3f0de50546aad25a872e3df059d277e776dda4269fa0d2cc8c2ee6ec9a022054e7fae5ca94d47534c86705857c24ceea3ad51c69dd6051c5850304880fc43a012103cb11a1bacc223d98d91f1946c6752e358a5eb1a1c983b3e6fb15378f453b76bd00000000";
97+
let tx: Transaction =
98+
encode::deserialize(&<Vec<u8>>::from_hex(tx_hex).unwrap()[..]).unwrap();
99+
100+
let txid = tx.compute_txid();
101+
102+
let id_0 = ChannelId::v1_from_funding_outpoint(OutPoint { txid, index: 0 });
103+
let expected_0 = "3e88dd7165faf7be58b3c5bb2c9c452aebef682807ea57080f62e6f6e113c25e";
104+
assert_eq!(&id_0.0[..], &Vec::<u8>::from_hex(expected_0).unwrap()[..]);
105+
106+
let id_1 = ChannelId::v1_from_funding_outpoint(OutPoint { txid, index: 1 });
107+
let expected_1 = "3e88dd7165faf7be58b3c5bb2c9c452aebef682807ea57080f62e6f6e113c25f";
108+
assert_eq!(&id_1.0[..], &Vec::<u8>::from_hex(expected_1).unwrap()[..]);
110109
}
111110
}

0 commit comments

Comments
 (0)