Skip to content

Commit e11b30c

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 6d9c676 commit e11b30c

File tree

1 file changed

+63
-32
lines changed

1 file changed

+63
-32
lines changed

lightning/src/ln/blinded_payment_tests.rs

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

12-
use bitcoin::hex::DisplayHex;
13-
use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey, schnorr};
14-
use bitcoin::secp256k1::ecdh::SharedSecret;
15-
use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
16-
use crate::blinded_path;
17-
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+
};
1814
use crate::blinded_path::utils::is_padded;
15+
use crate::blinded_path::{self, BlindedHop};
1916
use crate::events::{Event, HTLCHandlingFailureType, PaymentFailureReason};
20-
use crate::ln::types::ChannelId;
21-
use crate::types::payment::{PaymentHash, PaymentSecret};
22-
use crate::ln::channelmanager;
23-
use crate::ln::channelmanager::{HTLCFailureMsg, PaymentId, RecipientOnionFields};
24-
use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
17+
use crate::ln::channelmanager::{self, HTLCFailureMsg, PaymentId, RecipientOnionFields};
2518
use crate::ln::functional_test_utils::*;
2619
use crate::ln::inbound_payment::ExpandedKey;
27-
use crate::ln::msgs;
28-
use crate::ln::msgs::{BaseMessageHandler, ChannelMessageHandler, UnsignedGossipMessage, MessageSendEvent};
20+
use crate::ln::msgs::{
21+
self, BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, UnsignedGossipMessage,
22+
};
2923
use crate::ln::onion_payment;
3024
use crate::ln::onion_utils::{self, LocalHTLCFailureReason};
3125
use crate::ln::outbound_payment::{Retry, IDEMPOTENCY_TIMEOUT_TICKS};
26+
use crate::ln::types::ChannelId;
3227
use crate::offers::invoice::UnsignedBolt12Invoice;
3328
use crate::prelude::*;
34-
use crate::routing::router::{BlindedTail, Path, Payee, PaymentParameters, RouteHop, RouteParameters, TrampolineHop};
29+
use crate::routing::router::{
30+
BlindedTail, Path, Payee, PaymentParameters, Route, RouteHop, RouteParameters, TrampolineHop,
31+
};
3532
use crate::sign::{NodeSigner, PeerStorageKey, ReceiveAuthKey, Recipient};
33+
use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
34+
use crate::types::payment::{PaymentHash, PaymentSecret};
3635
use crate::util::config::UserConfig;
3736
use crate::util::ser::{WithoutLength, Writeable};
38-
use crate::util::test_utils::{self, bytes_from_hex, secret_from_hex, pubkey_from_hex};
37+
use crate::util::test_utils::{self, bytes_from_hex, pubkey_from_hex, secret_from_hex};
38+
use bitcoin::hex::DisplayHex;
39+
use bitcoin::secp256k1::ecdh::SharedSecret;
40+
use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
41+
use bitcoin::secp256k1::{schnorr, PublicKey, Scalar, Secp256k1, SecretKey};
3942
use lightning_invoice::RawBolt11Invoice;
4043
use types::features::Features;
41-
use crate::blinded_path::BlindedHop;
42-
use crate::routing::router::Route;
4344

45+
#[rustfmt::skip]
4446
pub fn blinded_payment_path(
4547
payment_secret: PaymentSecret, intro_node_min_htlc: u64, intro_node_max_htlc: u64,
4648
node_ids: Vec<PublicKey>, channel_upds: &[&msgs::UnsignedChannelUpdate],
@@ -93,20 +95,24 @@ pub fn blinded_payment_path(
9395
}
9496

9597
pub fn get_blinded_route_parameters(
96-
amt_msat: u64, payment_secret: PaymentSecret, intro_node_min_htlc: u64, intro_node_max_htlc: u64,
97-
node_ids: Vec<PublicKey>, channel_upds: &[&msgs::UnsignedChannelUpdate],
98-
keys_manager: &test_utils::TestKeysInterface
98+
amt_msat: u64, payment_secret: PaymentSecret, intro_node_min_htlc: u64,
99+
intro_node_max_htlc: u64, node_ids: Vec<PublicKey>,
100+
channel_upds: &[&msgs::UnsignedChannelUpdate], keys_manager: &test_utils::TestKeysInterface,
99101
) -> RouteParameters {
100102
RouteParameters::from_payment_params_and_value(
101-
PaymentParameters::blinded(vec![
102-
blinded_payment_path(
103-
payment_secret, intro_node_min_htlc, intro_node_max_htlc, node_ids, channel_upds,
104-
keys_manager
105-
)
106-
]), amt_msat
103+
PaymentParameters::blinded(vec![blinded_payment_path(
104+
payment_secret,
105+
intro_node_min_htlc,
106+
intro_node_max_htlc,
107+
node_ids,
108+
channel_upds,
109+
keys_manager,
110+
)]),
111+
amt_msat,
107112
)
108113
}
109114

115+
#[rustfmt::skip]
110116
pub fn fail_blinded_htlc_backwards(
111117
payment_hash: PaymentHash, intro_node_idx: usize, nodes: &[&Node],
112118
retry_expected: bool
@@ -148,6 +154,7 @@ fn one_hop_blinded_path() {
148154
do_one_hop_blinded_path(false);
149155
}
150156

157+
#[rustfmt::skip]
151158
fn do_one_hop_blinded_path(success: bool) {
152159
let chanmon_cfgs = create_chanmon_cfgs(2);
153160
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -190,6 +197,7 @@ fn do_one_hop_blinded_path(success: bool) {
190197
}
191198

192199
#[test]
200+
#[rustfmt::skip]
193201
fn mpp_to_one_hop_blinded_path() {
194202
let chanmon_cfgs = create_chanmon_cfgs(4);
195203
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
@@ -269,6 +277,7 @@ fn mpp_to_one_hop_blinded_path() {
269277
}
270278

271279
#[test]
280+
#[rustfmt::skip]
272281
fn mpp_to_three_hop_blinded_paths() {
273282
let chanmon_cfgs = create_chanmon_cfgs(6);
274283
let node_cfgs = create_node_cfgs(6, &chanmon_cfgs);
@@ -362,6 +371,7 @@ fn forward_checks_failure() {
362371
do_forward_checks_failure(ForwardCheckFail::OutboundChannelCheck, false);
363372
}
364373

374+
#[rustfmt::skip]
365375
fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
366376
// Ensure we'll fail backwards properly if a forwarding check fails on initial update_add
367377
// receipt.
@@ -499,6 +509,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
499509
}
500510

501511
#[test]
512+
#[rustfmt::skip]
502513
fn failed_backwards_to_intro_node() {
503514
// Ensure the intro node will error backwards properly even if the downstream node did not blind
504515
// their error.
@@ -569,12 +580,14 @@ enum ProcessPendingHTLCsCheck {
569580
}
570581

571582
#[test]
583+
#[rustfmt::skip]
572584
fn forward_fail_in_process_pending_htlc_fwds() {
573585
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdPeerDisconnected, true);
574586
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdPeerDisconnected, false);
575587
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdChannelClosed, true);
576588
do_forward_fail_in_process_pending_htlc_fwds(ProcessPendingHTLCsCheck::FwdChannelClosed, false);
577589
}
590+
#[rustfmt::skip]
578591
fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck, intro_fails: bool) {
579592
// Ensure the intro node will error backwards properly if the HTLC fails in
580593
// process_pending_htlc_forwards.
@@ -684,6 +697,8 @@ fn blinded_intercept_payment() {
684697
do_blinded_intercept_payment(true);
685698
do_blinded_intercept_payment(false);
686699
}
700+
701+
#[rustfmt::skip]
687702
fn do_blinded_intercept_payment(intercept_node_fails: bool) {
688703
let chanmon_cfgs = create_chanmon_cfgs(3);
689704
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -766,6 +781,7 @@ fn do_blinded_intercept_payment(intercept_node_fails: bool) {
766781
}
767782

768783
#[test]
784+
#[rustfmt::skip]
769785
fn two_hop_blinded_path_success() {
770786
let chanmon_cfgs = create_chanmon_cfgs(3);
771787
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -787,6 +803,7 @@ fn two_hop_blinded_path_success() {
787803
}
788804

789805
#[test]
806+
#[rustfmt::skip]
790807
fn three_hop_blinded_path_success() {
791808
let chanmon_cfgs = create_chanmon_cfgs(5);
792809
let node_cfgs = create_node_cfgs(5, &chanmon_cfgs);
@@ -816,6 +833,7 @@ fn three_hop_blinded_path_success() {
816833
}
817834

818835
#[test]
836+
#[rustfmt::skip]
819837
fn three_hop_blinded_path_fail() {
820838
// Test that an intermediate blinded forwarding node gets failed back to with
821839
// malformed and also fails back themselves with malformed.
@@ -875,6 +893,7 @@ fn multi_hop_receiver_fail() {
875893
do_multi_hop_receiver_fail(ReceiveCheckFail::PaymentConstraints);
876894
}
877895

896+
#[rustfmt::skip]
878897
fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
879898
// Test that the receiver to a multihop blinded path fails back correctly.
880899
let chanmon_cfgs = create_chanmon_cfgs(3);
@@ -1075,6 +1094,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10751094
}
10761095

10771096
#[test]
1097+
#[rustfmt::skip]
10781098
fn blinded_path_retries() {
10791099
let chanmon_cfgs = create_chanmon_cfgs(4);
10801100
// Make one blinded path's fees slightly higher so they are tried in a deterministic order.
@@ -1182,6 +1202,7 @@ fn blinded_path_retries() {
11821202
}
11831203

11841204
#[test]
1205+
#[rustfmt::skip]
11851206
fn min_htlc() {
11861207
// The min htlc of a blinded path is the max (htlc_min - following_fees) along the path. Make sure
11871208
// the payment succeeds when we calculate the min htlc this way.
@@ -1258,6 +1279,7 @@ fn min_htlc() {
12581279
}
12591280

12601281
#[test]
1282+
#[rustfmt::skip]
12611283
fn conditionally_round_fwd_amt() {
12621284
// Previously, the (rng-found) feerates below caught a bug where an intermediate node would
12631285
// 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() {
13081330
expect_payment_sent(&nodes[0], payment_preimage, Some(Some(expected_fee)), true, true);
13091331
}
13101332

1311-
13121333
#[test]
1334+
#[rustfmt::skip]
13131335
fn custom_tlvs_to_blinded_path() {
13141336
let chanmon_cfgs = create_chanmon_cfgs(2);
13151337
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1364,6 +1386,7 @@ fn custom_tlvs_to_blinded_path() {
13641386
}
13651387

13661388
#[test]
1389+
#[rustfmt::skip]
13671390
fn fails_receive_tlvs_authentication() {
13681391
let chanmon_cfgs = create_chanmon_cfgs(2);
13691392
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -1453,6 +1476,7 @@ fn fails_receive_tlvs_authentication() {
14531476
}
14541477

14551478
#[test]
1479+
#[rustfmt::skip]
14561480
fn blinded_payment_path_padding() {
14571481
// Make sure that for a blinded payment path, all encrypted payloads are padded to equal lengths.
14581482
let chanmon_cfgs = create_chanmon_cfgs(5);
@@ -1490,7 +1514,7 @@ fn blinded_payment_path_padding() {
14901514

14911515
fn update_add_msg(
14921516
amount_msat: u64, cltv_expiry: u32, blinding_point: Option<PublicKey>,
1493-
onion_routing_packet: msgs::OnionPacket
1517+
onion_routing_packet: msgs::OnionPacket,
14941518
) -> msgs::UpdateAddHTLC {
14951519
msgs::UpdateAddHTLC {
14961520
channel_id: ChannelId::from_bytes([0; 32]),
@@ -1506,6 +1530,7 @@ fn update_add_msg(
15061530
}
15071531

15081532
#[test]
1533+
#[rustfmt::skip]
15091534
fn route_blinding_spec_test_vector() {
15101535
let mut secp_ctx = Secp256k1::new();
15111536
let bob_secret = secret_from_hex("4242424242424242424242424242424242424242424242424242424242424242");
@@ -1736,6 +1761,7 @@ fn route_blinding_spec_test_vector() {
17361761
}
17371762

17381763
#[test]
1764+
#[rustfmt::skip]
17391765
fn test_combined_trampoline_onion_creation_vectors() {
17401766
// As per https://github.com/lightning/bolts/blob/fa0594ac2af3531d734f1d707a146d6e13679451/bolt04/trampoline-to-blinded-path-payment-onion-test.json#L251
17411767

@@ -1819,6 +1845,7 @@ fn test_combined_trampoline_onion_creation_vectors() {
18191845
}
18201846

18211847
#[test]
1848+
#[rustfmt::skip]
18221849
fn test_trampoline_inbound_payment_decoding() {
18231850
let secp_ctx = Secp256k1::new();
18241851
let session_priv = secret_from_hex("0303030303030303030303030303030303030303030303030303030303030303");
@@ -1965,6 +1992,7 @@ fn test_trampoline_inbound_payment_decoding() {
19651992
}
19661993

19671994
#[test]
1995+
#[rustfmt::skip]
19681996
fn test_trampoline_forward_payload_encoded_as_receive() {
19691997
// Test that we'll fail backwards as expected when receiving a well-formed blinded forward
19701998
// trampoline onion payload with no next hop present.
@@ -2152,6 +2180,7 @@ fn test_trampoline_forward_payload_encoded_as_receive() {
21522180
}
21532181
}
21542182

2183+
#[rustfmt::skip]
21552184
fn do_test_trampoline_single_hop_receive(success: bool) {
21562185
const TOTAL_NODE_COUNT: usize = 3;
21572186
let secp_ctx = Secp256k1::new();
@@ -2253,6 +2282,7 @@ fn test_trampoline_single_hop_receive() {
22532282
do_test_trampoline_single_hop_receive(false);
22542283
}
22552284

2285+
#[rustfmt::skip]
22562286
fn do_test_trampoline_unblinded_receive(success: bool) {
22572287
// Simulate a payment of A (0) -> B (1) -> C(Trampoline) (2)
22582288

@@ -2403,11 +2433,12 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
24032433

24042434
#[test]
24052435
fn test_trampoline_unblinded_receive() {
2406-
do_test_trampoline_unblinded_receive(true);
2407-
do_test_trampoline_unblinded_receive(false);
2436+
do_test_trampoline_unblinded_receive(true);
2437+
do_test_trampoline_unblinded_receive(false);
24082438
}
24092439

24102440
#[test]
2441+
#[rustfmt::skip]
24112442
fn test_trampoline_forward_rejection() {
24122443
const TOTAL_NODE_COUNT: usize = 3;
24132444

0 commit comments

Comments
 (0)