ln/fmt: move rustfmt_skip to per-function in blinded_payment_tests
What changed, and why it matters
This commit is a code-style cleanup in a test file. It removes a file-wide directive that told the Rust formatter to ignore the file, and instead marks individual helper functions to skip formatting. The actual test logic and program behavior are unchanged.
No security action needed. This is a formatting-only refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors formatting directives in lightning/src/ln/blinded_payment_tests.rs. It deletes the top-level #![cfg_attr(rustfmt, rustfmt_skip)] attribute, applies rustfmt to the imports and one function signature, and adds #[rustfmt::skip] attributes to selected functions. No functional code changes are present.
Changed components
lightning/src/ln/blinded_payment_tests.rsInspect captured patch +63 / −32
diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs
index 3dd6274..c30a741 100644
--- a/lightning/src/ln/blinded_payment_tests.rs
+++ b/lightning/src/ln/blinded_payment_tests.rs
@@ -1,5 +1,3 @@
-#![cfg_attr(rustfmt, rustfmt_skip)]
-
// This file is Copyright its original authors, visible in version control
// history.
//
@@ -9,38 +7,42 @@
// You may not use this file except in accordance with one or both of these
// licenses.
-use bitcoin::hex::DisplayHex;
-use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey, schnorr};
-use bitcoin::secp256k1::ecdh::SharedSecret;
-use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
-use crate::blinded_path;
-use crate::blinded_path::payment::{BlindedPaymentPath, Bolt12RefundContext, ForwardTlvs, PaymentConstraints, PaymentContext, PaymentForwardNode, PaymentRelay, ReceiveTlvs, PAYMENT_PADDING_ROUND_OFF};
+use crate::blinded_path::payment::{
+ BlindedPaymentPath, Bolt12RefundContext, ForwardTlvs, PaymentConstraints, PaymentContext,
+ PaymentForwardNode, PaymentRelay, ReceiveTlvs, PAYMENT_PADDING_ROUND_OFF,
+};
use crate::blinded_path::utils::is_padded;
+use crate::blinded_path::{self, BlindedHop};
use crate::events::{Event, HTLCHandlingFailureType, PaymentFailureReason};
-use crate::ln::types::ChannelId;
-use crate::types::payment::{PaymentHash, PaymentSecret};
-use crate::ln::channelmanager;
-use crate::ln::channelmanager::{HTLCFailureMsg, PaymentId, RecipientOnionFields};
-use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
+use crate::ln::channelmanager::{self, HTLCFailureMsg, PaymentId, RecipientOnionFields};
use crate::ln::functional_test_utils::*;
use crate::ln::inbound_payment::ExpandedKey;
-use crate::ln::msgs;
-use crate::ln::msgs::{BaseMessageHandler, ChannelMessageHandler, UnsignedGossipMessage, MessageSendEvent};
+use crate::ln::msgs::{
+ self, BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, UnsignedGossipMessage,
+};
use crate::ln::onion_payment;
use crate::ln::onion_utils::{self, LocalHTLCFailureReason};
use crate::ln::outbound_payment::{Retry, IDEMPOTENCY_TIMEOUT_TICKS};
+use crate::ln::types::ChannelId;
use crate::offers::invoice::UnsignedBolt12Invoice;
use crate::prelude::*;
-use crate::routing::router::{BlindedTail, Path, Payee, PaymentParameters, RouteHop, RouteParameters, TrampolineHop};
+use crate::routing::router::{
+ BlindedTail, Path, Payee, PaymentParameters, Route, RouteHop, RouteParameters, TrampolineHop,
+};
use crate::sign::{NodeSigner, PeerStorageKey, ReceiveAuthKey, Recipient};
+use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
+use crate::types::payment::{PaymentHash, PaymentSecret};
use crate::util::config::UserConfig;
use crate::util::ser::{WithoutLength, Writeable};
-use crate::util::test_utils::{self, bytes_from_hex, secret_from_hex, pubkey_from_hex};
+use crate::util::test_utils::{self, bytes_from_hex, pubkey_from_hex, secret_from_hex};
+use bitcoin::hex::DisplayHex;
+use bitcoin::secp256k1::ecdh::SharedSecret;
+use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
+use bitcoin::secp256k1::{schnorr, PublicKey, Scalar, Secp256k1, SecretKey};
use lightning_invoice::RawBolt11Invoice;
use types::features::Features;
-use crate::blinded_path::BlindedHop;
-use crate::routing::router::Route;
+#[rustfmt::skip]
pub fn blinded_payment_path(
payment_secret: PaymentSecret, intro_node_min_htlc: u64, intro_node_max_htlc: u64,
node_ids: Vec<PublicKey>, channel_upds: &[&msgs::UnsignedChannelUpdate],
@@ -93,20 +95,24 @@ pub fn blinded_payment_path(
}
pub fn get_blinded_route_parameters(
- amt_msat: u64, payment_secret: PaymentSecret, intro_node_min_htlc: u64, intro_node_max_htlc: u64,
- node_ids: Vec<PublicKey>, channel_upds: &[&msgs::UnsignedChannelUpdate],
- keys_manager: &test_utils::TestKeysInterface
+ amt_msat: u64, payment_secret: PaymentSecret, intro_node_min_htlc: u64,
+ intro_node_max_htlc: u64, node_ids: Vec<PublicKey>,
+ channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface,
) -> RouteParameters {
RouteParameters::from_payment_params_and_value(
- PaymentParameters::blinded(vec![
- blinded_payment_path(
- payment_secret, intro_node_min_htlc, intro_node_max_htlc, node_ids, channel_upds,
- keys_manager
- )
- ]), amt_msat
+ PaymentParameters::blinded(vec![blinded_payment_path(
+ payment_secret,
+ intro_node_min_htlc,
+ intro_node_max_htlc,
+ node_ids,
+ channel_upds,
+ keys_manager,
+ )]),
+ amt_msat,
)
}
+#[rustfmt::skip]
pub fn fail_blinded_htlc_backwards(
payment_hash: PaymentHash, intro_node_idx: usize, nodes: &[&Node],
retry_expected: bool
@@ -148,6 +154,7 @@ fn one_hop_blinded_path() {
do_one_hop_blinded_path(false);
}
+#[rustfmt::skip]
fn do_one_hop_blinded_path(success: bool) {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -190,6 +197,7 @@ fn do_one_hop_blinded_path(success: bool) {
}
#[test]
+#[rustfmt::skip]
fn mpp_to_one_hop_blinded_path() {
let chanmon_cfgs = create_chanmon_cfgs(4);
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
@@ -269,6 +277,7 @@ fn mpp_to_one_hop_blinded_path() {
}
#[test]
+#[rustfmt::skip]
fn mpp_to_three_hop_blinded_paths() {
let chanmon_cfgs = create_chanmon_cfgs(6);
let node_cfgs = create_node_cfgs(6, &chanmon_cfgs);
@@ -362,6 +371,7 @@ fn forward_checks_failure() {
do_forward_checks_failure(ForwardCheckFail::OutboundChannelCheck, false);
}
+#[rustfmt::skip]
fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
// Ensure we'll fail backwards properly if a forwarding check fails on initial update_add
// receipt.
@@ -499,6 +509,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
}
#[test]
+#[rustfmt::skip]
fn failed_backwards_to_intro_node() {
// Ensure the intro node will error backwards properly even if the downstream node did not blind
// their error.
@@ -569,12 +580,14 @@ enum ProcessPendingHTLCsCheck {
}
#[test]
+#[rustfmt::skip]
fn forward_fail_in_process_pending_htlc_fwds() {
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdPeerDisconnected, true);
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdPeerDisconnected, false);
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdChannelClosed, true);
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdChannelClosed, false);
}
+#[rustfmt::skip]
fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck, intro_fails: bool) {
// Ensure the intro node will error backwards properly if the HTLC fails in
// process_pending_htlc_forwards.
@@ -684,6 +697,8 @@ fn blinded_intercept_payment() {
do_blinded_intercept_payment(true);
do_blinded_intercept_payment(false);
}
+
+#[rustfmt::skip]
fn do_blinded_intercept_payment(intercept_node_fails: bool) {
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -766,6 +781,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
}
#[test]
+#[rustfmt::skip]
fn two_hop_blinded_path_success() {
let chanmon_cfgs = create_chanmon_cfgs(3);
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -787,6 +803,7 @@ fn two_hop_blinded_path_success() {
}
#[test]
+#[rustfmt::skip]
fn three_hop_blinded_path_success() {
let chanmon_cfgs = create_chanmon_cfgs(5);
let node_cfgs = create_node_cfgs(5, &chanmon_cfgs);
@@ -816,6 +833,7 @@ fn three_hop_blinded_path_success() {
}
#[test]
+#[rustfmt::skip]
fn three_hop_blinded_path_fail() {
// Test that an intermediate blinded forwarding node gets failed back to with
// malformed and also fails back themselves with malformed.
@@ -875,6 +893,7 @@ fn multi_hop_receiver_fail() {
do_multi_hop_receiver_fail(ReceiveCheckFail::PaymentConstraints);
}
+#[rustfmt::skip]
fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
// Test that the receiver to a multihop blinded path fails back correctly.
let chanmon_cfgs = create_chanmon_cfgs(3);
@@ -1075,6 +1094,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
}
#[test]
+#[rustfmt::skip]
fn blinded_path_retries() {
let chanmon_cfgs = create_chanmon_cfgs(4);
// Make one blinded path's fees slightly higher so they are tried in a deterministic order.
@@ -1182,6 +1202,7 @@ fn blinded_path_retries() {
}
#[test]
+#[rustfmt::skip]
fn min_htlc() {
// The min htlc of a blinded path is the max (htlc_min - following_fees) along the path. Make sure
// the payment succeeds when we calculate the min htlc this way.
@@ -1258,6 +1279,7 @@ fn min_htlc() {
}
#[test]
+#[rustfmt::skip]
fn conditionally_round_fwd_amt() {
// Previously, the (rng-found) feerates below caught a bug where an intermediate node would
// calculate an amt_to_forward that underpaid them by 1 msat, caused by rounding up the outbound
@@ -1308,8 +1330,8 @@ fn conditionally_round_fwd_amt() {
expect_payment_sent(&nodes[0], payment_preimage, Some(Some(expected_fee)), true, true);
}
-
#[test]
+#[rustfmt::skip]
fn custom_tlvs_to_blinded_path() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1364,6 +1386,7 @@ fn custom_tlvs_to_blinded_path() {
}
#[test]
+#[rustfmt::skip]
fn fails_receive_tlvs_authentication() {
let chanmon_cfgs = create_chanmon_cfgs(2);
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1453,6 +1476,7 @@ fn fails_receive_tlvs_authentication() {
}
#[test]
+#[rustfmt::skip]
fn blinded_payment_path_padding() {
// Make sure that for a blinded payment path, all encrypted payloads are padded to equal lengths.
let chanmon_cfgs = create_chanmon_cfgs(5);
@@ -1490,7 +1514,7 @@ fn blinded_payment_path_padding() {
fn update_add_msg(
amount_msat: u64, cltv_expiry: u32, blinding_point: Option<PublicKey>,
- onion_routing_packet: msgs::OnionPacket
+ onion_routing_packet: msgs::OnionPacket,
) -> msgs::UpdateAddHTLC {
msgs::UpdateAddHTLC {
channel_id: ChannelId::from_bytes([0; 32]),
@@ -1506,6 +1530,7 @@ fn update_add_msg(
}
#[test]
+#[rustfmt::skip]
fn route_blinding_spec_test_vector() {
let mut secp_ctx = Secp256k1::new();
let bob_secret = secret_from_hex("4242424242424242424242424242424242424242424242424242424242424242");
@@ -1736,6 +1761,7 @@ fn route_blinding_spec_test_vector() {
}
#[test]
+#[rustfmt::skip]
fn test_combined_trampoline_onion_creation_vectors() {
// As per https://github.com/lightning/bolts/blob/fa0594ac2af3531d734f1d707a146d6e13679451/bolt04/trampoline-to-blinded-path-payment-onion-test.json#L251
@@ -1819,6 +1845,7 @@ fn test_combined_trampoline_onion_creation_vectors() {
}
#[test]
+#[rustfmt::skip]
fn test_trampoline_inbound_payment_decoding() {
let secp_ctx = Secp256k1::new();
let session_priv = secret_from_hex("0303030303030303030303030303030303030303030303030303030303030303");
@@ -1965,6 +1992,7 @@ fn test_trampoline_inbound_payment_decoding() {
}
#[test]
+#[rustfmt::skip]
fn test_trampoline_forward_payload_encoded_as_receive() {
// Test that we'll fail backwards as expected when receiving a well-formed blinded forward
// trampoline onion payload with no next hop present.
@@ -2152,6 +2180,7 @@ fn test_trampoline_forward_payload_encoded_as_receive() {
}
}
+#[rustfmt::skip]
fn do_test_trampoline_single_hop_receive(success: bool) {
const TOTAL_NODE_COUNT: usize = 3;
let secp_ctx = Secp256k1::new();
@@ -2253,6 +2282,7 @@ fn test_trampoline_single_hop_receive() {
do_test_trampoline_single_hop_receive(false);
}
+#[rustfmt::skip]
fn do_test_trampoline_unblinded_receive(success: bool) {
// Simulate a payment of A (0) -> B (1) -> C(Trampoline) (2)
@@ -2403,11 +2433,12 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
#[test]
fn test_trampoline_unblinded_receive() {
- do_test_trampoline_unblinded_receive(true);
- do_test_trampoline_unblinded_receive(false);
+ do_test_trampoline_unblinded_receive(true);
+ do_test_trampoline_unblinded_receive(false);
}
#[test]
+#[rustfmt::skip]
fn test_trampoline_forward_rejection() {
const TOTAL_NODE_COUNT: usize = 3;
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.