Skip to content

Commit 16025f2

Browse files
committed
macro_export and rustfmt::skip fix
Those two directives don't seem to work together properly and make the build fail.
1 parent a3cfbe4 commit 16025f2

File tree

1 file changed

+82
-54
lines changed

1 file changed

+82
-54
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 82 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -841,30 +841,26 @@ pub fn get_updates_and_revoke<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &
841841
/// Gets an RAA and CS which were sent in response to a commitment update
842842
///
843843
/// Don't use this, use the identically-named function instead.
844-
#[rustfmt::skip]
845844
macro_rules! get_revoke_commit_msgs {
846845
($node: expr, $node_id: expr) => {
847846
$crate::ln::functional_test_utils::get_revoke_commit_msgs(&$node, &$node_id)
848-
}
847+
};
849848
}
850849

851850
/// Get an specific event message from the pending events queue.
852851
#[macro_export]
853-
#[rustfmt::skip]
854852
macro_rules! get_event_msg {
855-
($node: expr, $event_type: path, $node_id: expr) => {
856-
{
857-
let events = $node.node.get_and_clear_pending_msg_events();
858-
assert_eq!(events.len(), 1);
859-
match events[0] {
860-
$event_type { ref node_id, ref msg } => {
861-
assert_eq!(*node_id, $node_id);
862-
(*msg).clone()
863-
},
864-
_ => panic!("Unexpected event {:?}", events[0]),
865-
}
853+
($node: expr, $event_type: path, $node_id: expr) => {{
854+
let events = $node.node.get_and_clear_pending_msg_events();
855+
assert_eq!(events.len(), 1);
856+
match events[0] {
857+
$event_type { ref node_id, ref msg } => {
858+
assert_eq!(*node_id, $node_id);
859+
(*msg).clone()
860+
},
861+
_ => panic!("Unexpected event {:?}", events[0]),
866862
}
867-
}
863+
}};
868864
}
869865

870866
/// Get an error message from the pending events queue.
@@ -925,11 +921,10 @@ pub fn get_htlc_update_msgs(node: &Node, recipient: &PublicKey) -> msgs::Commitm
925921
/// Gets an UpdateHTLCs MessageSendEvent
926922
///
927923
/// Don't use this, use the identically-named function instead.
928-
#[rustfmt::skip]
929924
macro_rules! get_htlc_update_msgs {
930925
($node: expr, $node_id: expr) => {
931926
$crate::ln::functional_test_utils::get_htlc_update_msgs(&$node, &$node_id)
932-
}
927+
};
933928
}
934929

935930
/// Fetches the first `msg_event` to the passed `node_id` in the passed `msg_events` vec.
@@ -1103,24 +1098,19 @@ macro_rules! get_channel_type_features {
11031098

11041099
/// Returns a channel monitor given a channel id, making some naive assumptions
11051100
#[macro_export]
1106-
#[rustfmt::skip]
11071101
macro_rules! get_monitor {
1108-
($node: expr, $channel_id: expr) => {
1109-
{
1110-
$node.chain_monitor.chain_monitor.get_monitor($channel_id).unwrap()
1111-
}
1112-
}
1102+
($node: expr, $channel_id: expr) => {{
1103+
$node.chain_monitor.chain_monitor.get_monitor($channel_id).unwrap()
1104+
}};
11131105
}
11141106

11151107
/// Returns any local commitment transactions for the channel.
11161108
#[macro_export]
1117-
#[rustfmt::skip]
11181109
macro_rules! get_local_commitment_txn {
1119-
($node: expr, $channel_id: expr) => {
1120-
{
1121-
$crate::get_monitor!($node, $channel_id).unsafe_get_latest_holder_commitment_txn(&$node.logger)
1122-
}
1123-
}
1110+
($node: expr, $channel_id: expr) => {{
1111+
$crate::get_monitor!($node, $channel_id)
1112+
.unsafe_get_latest_holder_commitment_txn(&$node.logger)
1113+
}};
11241114
}
11251115

11261116
/// Check the error from attempting a payment.
@@ -1172,11 +1162,10 @@ pub fn check_added_monitors<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &H,
11721162
///
11731163
/// Don't use this, use the identically-named function instead.
11741164
#[macro_export]
1175-
#[rustfmt::skip]
11761165
macro_rules! check_added_monitors {
11771166
($node: expr, $count: expr) => {
11781167
$crate::ln::functional_test_utils::check_added_monitors(&$node, $count);
1179-
}
1168+
};
11801169
}
11811170

11821171
#[rustfmt::skip]
@@ -1818,11 +1807,10 @@ pub fn check_closed_broadcast(node: &Node, num_channels: usize, with_error_msg:
18181807
///
18191808
/// Don't use this, use the identically-named function instead.
18201809
#[macro_export]
1821-
#[rustfmt::skip]
18221810
macro_rules! check_closed_broadcast {
18231811
($node: expr, $with_error_msg: expr) => {
18241812
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, 1, $with_error_msg).pop()
1825-
}
1813+
};
18261814
}
18271815

18281816
#[derive(Default)]
@@ -1915,15 +1903,27 @@ pub fn check_closed_event(node: &Node, events_count: usize, expected_reason: Clo
19151903
///
19161904
/// Don't use this, use the identically-named function instead.
19171905
#[macro_export]
1918-
#[rustfmt::skip]
19191906
macro_rules! check_closed_event {
19201907
($node: expr, $events: expr, $reason: expr, $counterparty_node_ids: expr, $channel_capacity: expr) => {
1921-
check_closed_event!($node, $events, $reason, false, $counterparty_node_ids, $channel_capacity);
1908+
check_closed_event!(
1909+
$node,
1910+
$events,
1911+
$reason,
1912+
false,
1913+
$counterparty_node_ids,
1914+
$channel_capacity
1915+
);
19221916
};
19231917
($node: expr, $events: expr, $reason: expr, $is_check_discard_funding: expr, $counterparty_node_ids: expr, $channel_capacity: expr) => {
1924-
$crate::ln::functional_test_utils::check_closed_event(&$node, $events, $reason,
1925-
$is_check_discard_funding, &$counterparty_node_ids, $channel_capacity);
1926-
}
1918+
$crate::ln::functional_test_utils::check_closed_event(
1919+
&$node,
1920+
$events,
1921+
$reason,
1922+
$is_check_discard_funding,
1923+
&$counterparty_node_ids,
1924+
$channel_capacity,
1925+
);
1926+
};
19271927
}
19281928

19291929
#[rustfmt::skip]
@@ -2292,7 +2292,6 @@ pub fn get_payment_preimage_hash(recipient: &Node, min_value_msat: Option<u64>,
22922292
///
22932293
/// Don't use this, use the identically-named function instead.
22942294
#[macro_export]
2295-
#[rustfmt::skip]
22962295
macro_rules! get_payment_preimage_hash {
22972296
($dest_node: expr) => {
22982297
get_payment_preimage_hash!($dest_node, None)
@@ -2301,7 +2300,11 @@ macro_rules! get_payment_preimage_hash {
23012300
crate::get_payment_preimage_hash!($dest_node, $min_value_msat, None)
23022301
};
23032302
($dest_node: expr, $min_value_msat: expr, $min_final_cltv_expiry_delta: expr) => {
2304-
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$dest_node, $min_value_msat, $min_final_cltv_expiry_delta)
2303+
$crate::ln::functional_test_utils::get_payment_preimage_hash(
2304+
&$dest_node,
2305+
$min_value_msat,
2306+
$min_final_cltv_expiry_delta,
2307+
)
23052308
};
23062309
}
23072310

@@ -2344,24 +2347,41 @@ macro_rules! get_route {
23442347
}
23452348

23462349
#[macro_export]
2347-
#[rustfmt::skip]
23482350
macro_rules! get_route_and_payment_hash {
23492351
($send_node: expr, $recv_node: expr, $recv_value: expr) => {{
2350-
let payment_params = $crate::routing::router::PaymentParameters::from_node_id($recv_node.node.get_our_node_id(), TEST_FINAL_CLTV)
2351-
.with_bolt11_features($recv_node.node.bolt11_invoice_features()).unwrap();
2352+
let payment_params = $crate::routing::router::PaymentParameters::from_node_id(
2353+
$recv_node.node.get_our_node_id(),
2354+
TEST_FINAL_CLTV,
2355+
)
2356+
.with_bolt11_features($recv_node.node.bolt11_invoice_features())
2357+
.unwrap();
23522358
$crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value)
23532359
}};
23542360
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr) => {{
2355-
$crate::get_route_and_payment_hash!($send_node, $recv_node, $payment_params, $recv_value, None)
2361+
$crate::get_route_and_payment_hash!(
2362+
$send_node,
2363+
$recv_node,
2364+
$payment_params,
2365+
$recv_value,
2366+
None
2367+
)
23562368
}};
23572369
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $max_total_routing_fee_msat: expr) => {{
2358-
let mut route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);
2370+
let mut route_params =
2371+
$crate::routing::router::RouteParameters::from_payment_params_and_value(
2372+
$payment_params,
2373+
$recv_value,
2374+
);
23592375
route_params.max_total_routing_fee_msat = $max_total_routing_fee_msat;
23602376
let (payment_preimage, payment_hash, payment_secret) =
2361-
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$recv_node, Some($recv_value), None);
2377+
$crate::ln::functional_test_utils::get_payment_preimage_hash(
2378+
&$recv_node,
2379+
Some($recv_value),
2380+
None,
2381+
);
23622382
let route = $crate::ln::functional_test_utils::get_route(&$send_node, &route_params);
23632383
(route.unwrap(), payment_hash, payment_preimage, payment_secret)
2364-
}}
2384+
}};
23652385
}
23662386

23672387
#[rustfmt::skip]
@@ -2474,22 +2494,30 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &H,
24742494
}
24752495

24762496
#[macro_export]
2477-
#[rustfmt::skip]
24782497
macro_rules! expect_payment_sent {
24792498
($node: expr, $expected_payment_preimage: expr) => {
24802499
$crate::expect_payment_sent!($node, $expected_payment_preimage, None::<u64>, true)
24812500
};
24822501
($node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr) => {
2483-
$crate::expect_payment_sent!($node, $expected_payment_preimage, $expected_fee_msat_opt, true)
2502+
$crate::expect_payment_sent!(
2503+
$node,
2504+
$expected_payment_preimage,
2505+
$expected_fee_msat_opt,
2506+
true
2507+
)
24842508
};
24852509
($node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr, $expect_paths: expr) => {
2486-
$crate::ln::functional_test_utils::expect_payment_sent(&$node, $expected_payment_preimage,
2487-
$expected_fee_msat_opt.map(|o| Some(o)), $expect_paths, true)
2488-
}
2510+
$crate::ln::functional_test_utils::expect_payment_sent(
2511+
&$node,
2512+
$expected_payment_preimage,
2513+
$expected_fee_msat_opt.map(|o| Some(o)),
2514+
$expect_paths,
2515+
true,
2516+
)
2517+
};
24892518
}
24902519

24912520
#[macro_export]
2492-
#[rustfmt::skip]
24932521
macro_rules! expect_payment_path_successful {
24942522
($node: expr) => {
24952523
let events = $node.node.get_and_clear_pending_events();
@@ -2498,7 +2526,7 @@ macro_rules! expect_payment_path_successful {
24982526
$crate::events::Event::PaymentPathSuccessful { .. } => {},
24992527
_ => panic!("Unexpected event"),
25002528
}
2501-
}
2529+
};
25022530
}
25032531

25042532
/// Returns the total fee earned by this HTLC forward, in msat.

0 commit comments

Comments
 (0)