Skip to content

Commit 9ff8996

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 3c80c16 commit 9ff8996

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
@@ -846,30 +846,26 @@ pub fn get_updates_and_revoke<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &
846846
/// Gets an RAA and CS which were sent in response to a commitment update
847847
///
848848
/// Don't use this, use the identically-named function instead.
849-
#[rustfmt::skip]
850849
macro_rules! get_revoke_commit_msgs {
851850
($node: expr, $node_id: expr) => {
852851
$crate::ln::functional_test_utils::get_revoke_commit_msgs(&$node, &$node_id)
853-
}
852+
};
854853
}
855854

856855
/// Get an specific event message from the pending events queue.
857856
#[macro_export]
858-
#[rustfmt::skip]
859857
macro_rules! get_event_msg {
860-
($node: expr, $event_type: path, $node_id: expr) => {
861-
{
862-
let events = $node.node.get_and_clear_pending_msg_events();
863-
assert_eq!(events.len(), 1);
864-
match events[0] {
865-
$event_type { ref node_id, ref msg } => {
866-
assert_eq!(*node_id, $node_id);
867-
(*msg).clone()
868-
},
869-
_ => panic!("Unexpected event {:?}", events[0]),
870-
}
858+
($node: expr, $event_type: path, $node_id: expr) => {{
859+
let events = $node.node.get_and_clear_pending_msg_events();
860+
assert_eq!(events.len(), 1);
861+
match events[0] {
862+
$event_type { ref node_id, ref msg } => {
863+
assert_eq!(*node_id, $node_id);
864+
(*msg).clone()
865+
},
866+
_ => panic!("Unexpected event {:?}", events[0]),
871867
}
872-
}
868+
}};
873869
}
874870

875871
/// Get an error message from the pending events queue.
@@ -930,11 +926,10 @@ pub fn get_htlc_update_msgs(node: &Node, recipient: &PublicKey) -> msgs::Commitm
930926
/// Gets an UpdateHTLCs MessageSendEvent
931927
///
932928
/// Don't use this, use the identically-named function instead.
933-
#[rustfmt::skip]
934929
macro_rules! get_htlc_update_msgs {
935930
($node: expr, $node_id: expr) => {
936931
$crate::ln::functional_test_utils::get_htlc_update_msgs(&$node, &$node_id)
937-
}
932+
};
938933
}
939934

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

11091104
/// Returns a channel monitor given a channel id, making some naive assumptions
11101105
#[macro_export]
1111-
#[rustfmt::skip]
11121106
macro_rules! get_monitor {
1113-
($node: expr, $channel_id: expr) => {
1114-
{
1115-
$node.chain_monitor.chain_monitor.get_monitor($channel_id).unwrap()
1116-
}
1117-
}
1107+
($node: expr, $channel_id: expr) => {{
1108+
$node.chain_monitor.chain_monitor.get_monitor($channel_id).unwrap()
1109+
}};
11181110
}
11191111

11201112
/// Returns any local commitment transactions for the channel.
11211113
#[macro_export]
1122-
#[rustfmt::skip]
11231114
macro_rules! get_local_commitment_txn {
1124-
($node: expr, $channel_id: expr) => {
1125-
{
1126-
$crate::get_monitor!($node, $channel_id).unsafe_get_latest_holder_commitment_txn(&$node.logger)
1127-
}
1128-
}
1115+
($node: expr, $channel_id: expr) => {{
1116+
$crate::get_monitor!($node, $channel_id)
1117+
.unsafe_get_latest_holder_commitment_txn(&$node.logger)
1118+
}};
11291119
}
11301120

11311121
/// Check the error from attempting a payment.
@@ -1176,11 +1166,10 @@ pub fn check_added_monitors<CM: AChannelManager, H: NodeHolder<CM = CM>>(node: &
11761166
///
11771167
/// Don't use this, use the identically-named function instead.
11781168
#[macro_export]
1179-
#[rustfmt::skip]
11801169
macro_rules! check_added_monitors {
11811170
($node: expr, $count: expr) => {
11821171
$crate::ln::functional_test_utils::check_added_monitors(&$node, $count);
1183-
}
1172+
};
11841173
}
11851174

11861175
#[rustfmt::skip]
@@ -1828,11 +1817,10 @@ pub fn check_closed_broadcast(node: &Node, num_channels: usize, with_error_msg:
18281817
///
18291818
/// Don't use this, use the identically-named function instead.
18301819
#[macro_export]
1831-
#[rustfmt::skip]
18321820
macro_rules! check_closed_broadcast {
18331821
($node: expr, $with_error_msg: expr) => {
18341822
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, 1, $with_error_msg).pop()
1835-
}
1823+
};
18361824
}
18371825

18381826
#[derive(Default)]
@@ -1926,15 +1914,27 @@ pub fn check_closed_event(node: &Node, events_count: usize, expected_reason: Clo
19261914
///
19271915
/// Don't use this, use the identically-named function instead.
19281916
#[macro_export]
1929-
#[rustfmt::skip]
19301917
macro_rules! check_closed_event {
19311918
($node: expr, $events: expr, $reason: expr, $counterparty_node_ids: expr, $channel_capacity: expr) => {
1932-
check_closed_event!($node, $events, $reason, false, $counterparty_node_ids, $channel_capacity);
1919+
check_closed_event!(
1920+
$node,
1921+
$events,
1922+
$reason,
1923+
false,
1924+
$counterparty_node_ids,
1925+
$channel_capacity
1926+
);
19331927
};
19341928
($node: expr, $events: expr, $reason: expr, $is_check_discard_funding: expr, $counterparty_node_ids: expr, $channel_capacity: expr) => {
1935-
$crate::ln::functional_test_utils::check_closed_event(&$node, $events, $reason,
1936-
$is_check_discard_funding, &$counterparty_node_ids, $channel_capacity);
1937-
}
1929+
$crate::ln::functional_test_utils::check_closed_event(
1930+
&$node,
1931+
$events,
1932+
$reason,
1933+
$is_check_discard_funding,
1934+
&$counterparty_node_ids,
1935+
$channel_capacity,
1936+
);
1937+
};
19381938
}
19391939

19401940
#[rustfmt::skip]
@@ -2303,7 +2303,6 @@ pub fn get_payment_preimage_hash(recipient: &Node, min_value_msat: Option<u64>,
23032303
///
23042304
/// Don't use this, use the identically-named function instead.
23052305
#[macro_export]
2306-
#[rustfmt::skip]
23072306
macro_rules! get_payment_preimage_hash {
23082307
($dest_node: expr) => {
23092308
get_payment_preimage_hash!($dest_node, None)
@@ -2312,7 +2311,11 @@ macro_rules! get_payment_preimage_hash {
23122311
crate::get_payment_preimage_hash!($dest_node, $min_value_msat, None)
23132312
};
23142313
($dest_node: expr, $min_value_msat: expr, $min_final_cltv_expiry_delta: expr) => {
2315-
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$dest_node, $min_value_msat, $min_final_cltv_expiry_delta)
2314+
$crate::ln::functional_test_utils::get_payment_preimage_hash(
2315+
&$dest_node,
2316+
$min_value_msat,
2317+
$min_final_cltv_expiry_delta,
2318+
)
23162319
};
23172320
}
23182321

@@ -2355,24 +2358,41 @@ macro_rules! get_route {
23552358
}
23562359

23572360
#[macro_export]
2358-
#[rustfmt::skip]
23592361
macro_rules! get_route_and_payment_hash {
23602362
($send_node: expr, $recv_node: expr, $recv_value: expr) => {{
2361-
let payment_params = $crate::routing::router::PaymentParameters::from_node_id($recv_node.node.get_our_node_id(), TEST_FINAL_CLTV)
2362-
.with_bolt11_features($recv_node.node.bolt11_invoice_features()).unwrap();
2363+
let payment_params = $crate::routing::router::PaymentParameters::from_node_id(
2364+
$recv_node.node.get_our_node_id(),
2365+
TEST_FINAL_CLTV,
2366+
)
2367+
.with_bolt11_features($recv_node.node.bolt11_invoice_features())
2368+
.unwrap();
23632369
$crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value)
23642370
}};
23652371
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr) => {{
2366-
$crate::get_route_and_payment_hash!($send_node, $recv_node, $payment_params, $recv_value, None)
2372+
$crate::get_route_and_payment_hash!(
2373+
$send_node,
2374+
$recv_node,
2375+
$payment_params,
2376+
$recv_value,
2377+
None
2378+
)
23672379
}};
23682380
($send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $max_total_routing_fee_msat: expr) => {{
2369-
let mut route_params = $crate::routing::router::RouteParameters::from_payment_params_and_value($payment_params, $recv_value);
2381+
let mut route_params =
2382+
$crate::routing::router::RouteParameters::from_payment_params_and_value(
2383+
$payment_params,
2384+
$recv_value,
2385+
);
23702386
route_params.max_total_routing_fee_msat = $max_total_routing_fee_msat;
23712387
let (payment_preimage, payment_hash, payment_secret) =
2372-
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$recv_node, Some($recv_value), None);
2388+
$crate::ln::functional_test_utils::get_payment_preimage_hash(
2389+
&$recv_node,
2390+
Some($recv_value),
2391+
None,
2392+
);
23732393
let route = $crate::ln::functional_test_utils::get_route(&$send_node, &route_params);
23742394
(route.unwrap(), payment_hash, payment_preimage, payment_secret)
2375-
}}
2395+
}};
23762396
}
23772397

23782398
#[rustfmt::skip]
@@ -2485,22 +2505,30 @@ pub fn expect_payment_sent<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &H,
24852505
}
24862506

24872507
#[macro_export]
2488-
#[rustfmt::skip]
24892508
macro_rules! expect_payment_sent {
24902509
($node: expr, $expected_payment_preimage: expr) => {
24912510
$crate::expect_payment_sent!($node, $expected_payment_preimage, None::<u64>, true)
24922511
};
24932512
($node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr) => {
2494-
$crate::expect_payment_sent!($node, $expected_payment_preimage, $expected_fee_msat_opt, true)
2513+
$crate::expect_payment_sent!(
2514+
$node,
2515+
$expected_payment_preimage,
2516+
$expected_fee_msat_opt,
2517+
true
2518+
)
24952519
};
24962520
($node: expr, $expected_payment_preimage: expr, $expected_fee_msat_opt: expr, $expect_paths: expr) => {
2497-
$crate::ln::functional_test_utils::expect_payment_sent(&$node, $expected_payment_preimage,
2498-
$expected_fee_msat_opt.map(|o| Some(o)), $expect_paths, true)
2499-
}
2521+
$crate::ln::functional_test_utils::expect_payment_sent(
2522+
&$node,
2523+
$expected_payment_preimage,
2524+
$expected_fee_msat_opt.map(|o| Some(o)),
2525+
$expect_paths,
2526+
true,
2527+
)
2528+
};
25002529
}
25012530

25022531
#[macro_export]
2503-
#[rustfmt::skip]
25042532
macro_rules! expect_payment_path_successful {
25052533
($node: expr) => {
25062534
let events = $node.node.get_and_clear_pending_events();
@@ -2509,7 +2537,7 @@ macro_rules! expect_payment_path_successful {
25092537
$crate::events::Event::PaymentPathSuccessful { .. } => {},
25102538
_ => panic!("Unexpected event"),
25112539
}
2512-
}
2540+
};
25132541
}
25142542

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

0 commit comments

Comments
 (0)