Skip to content

Commit 8296b14

Browse files
committed
ln/fmt: move rustfmt_skip to per-function in blinded_payment_tests
To allow formatting on new code, move to per-function skips.
1 parent 6d4897c commit 8296b14

File tree

1 file changed

+63
-29
lines changed

1 file changed

+63
-29
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 63 additions & 29 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
//
@@ -9,39 +7,46 @@
97
// You may not use this file except in accordance with one or both of these
108
// licenses.
119

12-
use bitcoin::hashes::hex::FromHex;
13-
use bitcoin::hex::DisplayHex;
14-
use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey, schnorr};
15-
use bitcoin::secp256k1::ecdh::SharedSecret;
16-
use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
17-
use crate::blinded_path;
18-
use crate::blinded_path::payment::{BlindedPaymentPath, Bolt12RefundContext, ForwardTlvs, PaymentConstraints, PaymentContext, PaymentForwardNode, PaymentRelay, ReceiveTlvs, PAYMENT_PADDING_ROUND_OFF};
10+
use crate::blinded_path::payment::{
11+
BlindedPaymentPath, Bolt12RefundContext, ForwardTlvs, PaymentConstraints, PaymentContext,
12+
PaymentForwardNode, PaymentRelay, ReceiveTlvs, PAYMENT_PADDING_ROUND_OFF,
13+
};
1914
use crate::blinded_path::utils::is_padded;
15+
use crate::blinded_path::{self, BlindedHop};
2016
use crate::events::{Event, HTLCHandlingFailureType, PaymentFailureReason};
21-
use crate::ln::types::ChannelId;
22-
use crate::types::payment::{PaymentHash, PaymentSecret};
2317
use crate::ln::channelmanager;
2418
use crate::ln::channelmanager::{HTLCFailureMsg, PaymentId, RecipientOnionFields};
25-
use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
2619
use crate::ln::functional_test_utils::*;
2720
use crate::ln::inbound_payment::ExpandedKey;
2821
use crate::ln::msgs;
29-
use crate::ln::msgs::{BaseMessageHandler, ChannelMessageHandler, UnsignedGossipMessage, MessageSendEvent};
22+
use crate::ln::msgs::{
23+
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, UnsignedGossipMessage,
24+
};
3025
use crate::ln::onion_payment;
3126
use crate::ln::onion_utils::{self, LocalHTLCFailureReason};
3227
use crate::ln::outbound_payment::{Retry, IDEMPOTENCY_TIMEOUT_TICKS};
28+
use crate::ln::types::ChannelId;
3329
use crate::offers::invoice::UnsignedBolt12Invoice;
3430
use crate::prelude::*;
35-
use crate::routing::router::{BlindedTail, Path, Payee, PaymentParameters, RouteHop, RouteParameters, TrampolineHop};
31+
use crate::routing::router::Route;
32+
use crate::routing::router::{
33+
BlindedTail, Path, Payee, PaymentParameters, RouteHop, RouteParameters, TrampolineHop,
34+
};
3635
use crate::sign::{NodeSigner, PeerStorageKey, ReceiveAuthKey, Recipient};
36+
use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
37+
use crate::types::payment::{PaymentHash, PaymentSecret};
3738
use crate::util::config::UserConfig;
3839
use crate::util::ser::{WithoutLength, Writeable};
3940
use crate::util::test_utils;
41+
use bitcoin::hashes::hex::FromHex;
42+
use bitcoin::hex::DisplayHex;
43+
use bitcoin::secp256k1::ecdh::SharedSecret;
44+
use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
45+
use bitcoin::secp256k1::{schnorr, PublicKey, Scalar, Secp256k1, SecretKey};
4046
use lightning_invoice::RawBolt11Invoice;
4147
use types::features::Features;
42-
use crate::blinded_path::BlindedHop;
43-
use crate::routing::router::Route;
4448

49+
#[rustfmt::skip]
4550
pub fn blinded_payment_path(
4651
payment_secret: PaymentSecret, intro_node_min_htlc: u64, intro_node_max_htlc: u64,
4752
node_ids: Vec<PublicKey>, channel_upds: &[&msgs::UnsignedChannelUpdate],
@@ -94,20 +99,24 @@ pub fn blinded_payment_path(
9499
}
95100

96101
pub fn get_blinded_route_parameters(
97-
amt_msat: u64, payment_secret: PaymentSecret, intro_node_min_htlc: u64, intro_node_max_htlc: u64,
98-
node_ids: Vec<PublicKey>, channel_upds: &[&msgs::UnsignedChannelUpdate],
99-
keys_manager: &test_utils::TestKeysInterface
102+
amt_msat: u64, payment_secret: PaymentSecret, intro_node_min_htlc: u64,
103+
intro_node_max_htlc: u64, node_ids: Vec<PublicKey>,
104+
channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface,
100105
) -> RouteParameters {
101106
RouteParameters::from_payment_params_and_value(
102-
PaymentParameters::blinded(vec![
103-
blinded_payment_path(
104-
payment_secret, intro_node_min_htlc, intro_node_max_htlc, node_ids, channel_upds,
105-
keys_manager
106-
)
107-
]), amt_msat
107+
PaymentParameters::blinded(vec![blinded_payment_path(
108+
payment_secret,
109+
intro_node_min_htlc,
110+
intro_node_max_htlc,
111+
node_ids,
112+
channel_upds,
113+
keys_manager,
114+
)]),
115+
amt_msat,
108116
)
109117
}
110118

119+
#[rustfmt::skip]
111120
pub fn fail_blinded_htlc_backwards(
112121
payment_hash: PaymentHash, intro_node_idx: usize, nodes: &[&Node],
113122
retry_expected: bool
@@ -149,6 +158,7 @@ fn one_hop_blinded_path() {
149158
do_one_hop_blinded_path(false);
150159
}
151160

161+
#[rustfmt::skip]
152162
fn do_one_hop_blinded_path(success: bool) {
153163
let chanmon_cfgs = create_chanmon_cfgs(2);
154164
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -191,6 +201,7 @@ fn do_one_hop_blinded_path(success: bool) {
191201
}
192202

193203
#[test]
204+
#[rustfmt::skip]
194205
fn mpp_to_one_hop_blinded_path() {
195206
let chanmon_cfgs = create_chanmon_cfgs(4);
196207
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
@@ -270,6 +281,7 @@ fn mpp_to_one_hop_blinded_path() {
270281
}
271282

272283
#[test]
284+
#[rustfmt::skip]
273285
fn mpp_to_three_hop_blinded_paths() {
274286
let chanmon_cfgs = create_chanmon_cfgs(6);
275287
let node_cfgs = create_node_cfgs(6, &chanmon_cfgs);
@@ -363,6 +375,7 @@ fn forward_checks_failure() {
363375
do_forward_checks_failure(ForwardCheckFail::OutboundChannelCheck, false);
364376
}
365377

378+
#[rustfmt::skip]
366379
fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
367380
// Ensure we'll fail backwards properly if a forwarding check fails on initial update_add
368381
// receipt.
@@ -500,6 +513,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
500513
}
501514

502515
#[test]
516+
#[rustfmt::skip]
503517
fn failed_backwards_to_intro_node() {
504518
// Ensure the intro node will error backwards properly even if the downstream node did not blind
505519
// their error.
@@ -570,12 +584,14 @@ enum ProcessPendingHTLCsCheck {
570584
}
571585

572586
#[test]
587+
#[rustfmt::skip]
573588
fn forward_fail_in_process_pending_htlc_fwds() {
574589
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdPeerDisconnected, true);
575590
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdPeerDisconnected, false);
576591
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdChannelClosed, true);
577592
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdChannelClosed, false);
578593
}
594+
#[rustfmt::skip]
579595
fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck, intro_fails: bool) {
580596
// Ensure the intro node will error backwards properly if the HTLC fails in
581597
// process_pending_htlc_forwards.
@@ -685,6 +701,8 @@ fn blinded_intercept_payment() {
685701
do_blinded_intercept_payment(true);
686702
do_blinded_intercept_payment(false);
687703
}
704+
705+
#[rustfmt::skip]
688706
fn do_blinded_intercept_payment(intercept_node_fails: bool) {
689707
let chanmon_cfgs = create_chanmon_cfgs(3);
690708
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -767,6 +785,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
767785
}
768786

769787
#[test]
788+
#[rustfmt::skip]
770789
fn two_hop_blinded_path_success() {
771790
let chanmon_cfgs = create_chanmon_cfgs(3);
772791
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -788,6 +807,7 @@ fn two_hop_blinded_path_success() {
788807
}
789808

790809
#[test]
810+
#[rustfmt::skip]
791811
fn three_hop_blinded_path_success() {
792812
let chanmon_cfgs = create_chanmon_cfgs(5);
793813
let node_cfgs = create_node_cfgs(5, &chanmon_cfgs);
@@ -817,6 +837,7 @@ fn three_hop_blinded_path_success() {
817837
}
818838

819839
#[test]
840+
#[rustfmt::skip]
820841
fn three_hop_blinded_path_fail() {
821842
// Test that an intermediate blinded forwarding node gets failed back to with
822843
// malformed and also fails back themselves with malformed.
@@ -876,6 +897,7 @@ fn multi_hop_receiver_fail() {
876897
do_multi_hop_receiver_fail(ReceiveCheckFail::PaymentConstraints);
877898
}
878899

900+
#[rustfmt::skip]
879901
fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
880902
// Test that the receiver to a multihop blinded path fails back correctly.
881903
let chanmon_cfgs = create_chanmon_cfgs(3);
@@ -1076,6 +1098,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10761098
}
10771099

10781100
#[test]
1101+
#[rustfmt::skip]
10791102
fn blinded_path_retries() {
10801103
let chanmon_cfgs = create_chanmon_cfgs(4);
10811104
// Make one blinded path's fees slightly higher so they are tried in a deterministic order.
@@ -1183,6 +1206,7 @@ fn blinded_path_retries() {
11831206
}
11841207

11851208
#[test]
1209+
#[rustfmt::skip]
11861210
fn min_htlc() {
11871211
// The min htlc of a blinded path is the max (htlc_min - following_fees) along the path. Make sure
11881212
// the payment succeeds when we calculate the min htlc this way.
@@ -1259,6 +1283,7 @@ fn min_htlc() {
12591283
}
12601284

12611285
#[test]
1286+
#[rustfmt::skip]
12621287
fn conditionally_round_fwd_amt() {
12631288
// Previously, the (rng-found) feerates below caught a bug where an intermediate node would
12641289
// calculate an amt_to_forward that underpaid them by 1 msat, caused by rounding up the outbound
@@ -1309,8 +1334,8 @@ fn conditionally_round_fwd_amt() {
13091334
expect_payment_sent(&nodes[0], payment_preimage, Some(Some(expected_fee)), true, true);
13101335
}
13111336

1312-
13131337
#[test]
1338+
#[rustfmt::skip]
13141339
fn custom_tlvs_to_blinded_path() {
13151340
let chanmon_cfgs = create_chanmon_cfgs(2);
13161341
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1365,6 +1390,7 @@ fn custom_tlvs_to_blinded_path() {
13651390
}
13661391

13671392
#[test]
1393+
#[rustfmt::skip]
13681394
fn fails_receive_tlvs_authentication() {
13691395
let chanmon_cfgs = create_chanmon_cfgs(2);
13701396
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1454,6 +1480,7 @@ fn fails_receive_tlvs_authentication() {
14541480
}
14551481

14561482
#[test]
1483+
#[rustfmt::skip]
14571484
fn blinded_payment_path_padding() {
14581485
// Make sure that for a blinded payment path, all encrypted payloads are padded to equal lengths.
14591486
let chanmon_cfgs = create_chanmon_cfgs(5);
@@ -1503,7 +1530,7 @@ fn pubkey_from_hex(hex: &str) -> PublicKey {
15031530

15041531
fn update_add_msg(
15051532
amount_msat: u64, cltv_expiry: u32, blinding_point: Option<PublicKey>,
1506-
onion_routing_packet: msgs::OnionPacket
1533+
onion_routing_packet: msgs::OnionPacket,
15071534
) -> msgs::UpdateAddHTLC {
15081535
msgs::UpdateAddHTLC {
15091536
channel_id: ChannelId::from_bytes([0; 32]),
@@ -1519,6 +1546,7 @@ fn update_add_msg(
15191546
}
15201547

15211548
#[test]
1549+
#[rustfmt::skip]
15221550
fn route_blinding_spec_test_vector() {
15231551
let mut secp_ctx = Secp256k1::new();
15241552
let bob_secret = secret_from_hex("4242424242424242424242424242424242424242424242424242424242424242");
@@ -1749,6 +1777,7 @@ fn route_blinding_spec_test_vector() {
17491777
}
17501778

17511779
#[test]
1780+
#[rustfmt::skip]
17521781
fn test_combined_trampoline_onion_creation_vectors() {
17531782
// As per https://github.com/lightning/bolts/blob/fa0594ac2af3531d734f1d707a146d6e13679451/bolt04/trampoline-to-blinded-path-payment-onion-test.json#L251
17541783

@@ -1832,6 +1861,7 @@ fn test_combined_trampoline_onion_creation_vectors() {
18321861
}
18331862

18341863
#[test]
1864+
#[rustfmt::skip]
18351865
fn test_trampoline_inbound_payment_decoding() {
18361866
let secp_ctx = Secp256k1::new();
18371867
let session_priv = secret_from_hex("0303030303030303030303030303030303030303030303030303030303030303");
@@ -1978,6 +2008,7 @@ fn test_trampoline_inbound_payment_decoding() {
19782008
}
19792009

19802010
#[test]
2011+
#[rustfmt::skip]
19812012
fn test_trampoline_forward_payload_encoded_as_receive() {
19822013
// Test that we'll fail backwards as expected when receiving a well-formed blinded forward
19832014
// trampoline onion payload with no next hop present.
@@ -2165,6 +2196,7 @@ fn test_trampoline_forward_payload_encoded_as_receive() {
21652196
}
21662197
}
21672198

2199+
#[rustfmt::skip]
21682200
fn do_test_trampoline_single_hop_receive(success: bool) {
21692201
const TOTAL_NODE_COUNT: usize = 3;
21702202
let secp_ctx = Secp256k1::new();
@@ -2266,6 +2298,7 @@ fn test_trampoline_single_hop_receive() {
22662298
do_test_trampoline_single_hop_receive(false);
22672299
}
22682300

2301+
#[rustfmt::skip]
22692302
fn do_test_trampoline_unblinded_receive(success: bool) {
22702303
// Simulate a payment of A (0) -> B (1) -> C(Trampoline) (2)
22712304

@@ -2416,11 +2449,12 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
24162449

24172450
#[test]
24182451
fn test_trampoline_unblinded_receive() {
2419-
do_test_trampoline_unblinded_receive(true);
2420-
do_test_trampoline_unblinded_receive(false);
2452+
do_test_trampoline_unblinded_receive(true);
2453+
do_test_trampoline_unblinded_receive(false);
24212454
}
24222455

24232456
#[test]
2457+
#[rustfmt::skip]
24242458
fn test_trampoline_forward_rejection() {
24252459
const TOTAL_NODE_COUNT: usize = 3;
24262460

0 commit comments

Comments
 (0)