Skip to content

Commit a88062e

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 a88062e

File tree

1 file changed

+82
-42
lines changed

1 file changed

+82
-42
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 82 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -845,26 +845,24 @@ pub fn get_updates_and_revoke<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &
845845
macro_rules! get_revoke_commit_msgs {
846846
($node: expr, $node_id: expr) => {
847847
$crate::ln::functional_test_utils::get_revoke_commit_msgs(&$node, &$node_id)
848-
}
848+
};
849849
}
850850

851851
/// Get an specific event message from the pending events queue.
852852
#[macro_export]
853853
#[rustfmt::skip]
854854
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-
}
855+
($node: expr, $event_type: path, $node_id: expr) => {{
856+
let events = $node.node.get_and_clear_pending_msg_events();
857+
assert_eq!(events.len(), 1);
858+
match events[0] {
859+
$event_type { ref node_id, ref msg } => {
860+
assert_eq!(*node_id, $node_id);
861+
(*msg).clone()
862+
},
863+
_ => panic!("Unexpected event {:?}", events[0]),
866864
}
867-
}
865+
}};
868866
}
869867

870868
/// Get an error message from the pending events queue.
@@ -929,7 +927,7 @@ pub fn get_htlc_update_msgs(node: &Node, recipient: &PublicKey) -> msgs::Commitm
929927
macro_rules! get_htlc_update_msgs {
930928
($node: expr, $node_id: expr) => {
931929
$crate::ln::functional_test_utils::get_htlc_update_msgs(&$node, &$node_id)
932-
}
930+
};
933931
}
934932

935933
/// Fetches the first `msg_event` to the passed `node_id` in the passed `msg_events` vec.
@@ -1105,22 +1103,19 @@ macro_rules! get_channel_type_features {
11051103
#[macro_export]
11061104
#[rustfmt::skip]
11071105
macro_rules! get_monitor {
1108-
($node: expr, $channel_id: expr) => {
1109-
{
1110-
$node.chain_monitor.chain_monitor.get_monitor($channel_id).unwrap()
1111-
}
1112-
}
1106+
($node: expr, $channel_id: expr) => {{
1107+
$node.chain_monitor.chain_monitor.get_monitor($channel_id).unwrap()
1108+
}};
11131109
}
11141110

11151111
/// Returns any local commitment transactions for the channel.
11161112
#[macro_export]
11171113
#[rustfmt::skip]
11181114
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-
}
1115+
($node: expr, $channel_id: expr) => {{
1116+
$crate::get_monitor!($node, $channel_id)
1117+
.unsafe_get_latest_holder_commitment_txn(&$node.logger)
1118+
}};
11241119
}
11251120

11261121
/// Check the error from attempting a payment.
@@ -1176,7 +1171,7 @@ pub fn check_added_monitors<CM: AChannelManager, H: NodeHolder<CM=CM>>(node: &H,
11761171
macro_rules! check_added_monitors {
11771172
($node: expr, $count: expr) => {
11781173
$crate::ln::functional_test_utils::check_added_monitors(&$node, $count);
1179-
}
1174+
};
11801175
}
11811176

11821177
#[rustfmt::skip]
@@ -1822,7 +1817,7 @@ pub fn check_closed_broadcast(node: &Node, num_channels: usize, with_error_msg:
18221817
macro_rules! check_closed_broadcast {
18231818
($node: expr, $with_error_msg: expr) => {
18241819
$crate::ln::functional_test_utils::check_closed_broadcast(&$node, 1, $with_error_msg).pop()
1825-
}
1820+
};
18261821
}
18271822

18281823
#[derive(Default)]
@@ -1918,12 +1913,25 @@ pub fn check_closed_event(node: &Node, events_count: usize, expected_reason: Clo
19181913
#[rustfmt::skip]
19191914
macro_rules! check_closed_event {
19201915
($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);
1916+
check_closed_event!(
1917+
$node,
1918+
$events,
1919+
$reason,
1920+
false,
1921+
$counterparty_node_ids,
1922+
$channel_capacity
1923+
);
19221924
};
19231925
($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-
}
1926+
$crate::ln::functional_test_utils::check_closed_event(
1927+
&$node,
1928+
$events,
1929+
$reason,
1930+
$is_check_discard_funding,
1931+
&$counterparty_node_ids,
1932+
$channel_capacity,
1933+
);
1934+
};
19271935
}
19281936

19291937
#[rustfmt::skip]
@@ -2301,7 +2309,11 @@ macro_rules! get_payment_preimage_hash {
23012309
crate::get_payment_preimage_hash!($dest_node, $min_value_msat, None)
23022310
};
23032311
($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)
2312+
$crate::ln::functional_test_utils::get_payment_preimage_hash(
2313+
&$dest_node,
2314+
$min_value_msat,
2315+
$min_final_cltv_expiry_delta,
2316+
)
23052317
};
23062318
}
23072319

@@ -2347,21 +2359,39 @@ macro_rules! get_route {
23472359
#[rustfmt::skip]
23482360
macro_rules! get_route_and_payment_hash {
23492361
($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();
2362+
let payment_params = $crate::routing::router::PaymentParameters::from_node_id(
2363+
$recv_node.node.get_our_node_id(),
2364+
TEST_FINAL_CLTV,
2365+
)
2366+
.with_bolt11_features($recv_node.node.bolt11_invoice_features())
2367+
.unwrap();
23522368
$crate::get_route_and_payment_hash!($send_node, $recv_node, payment_params, $recv_value)
23532369
}};
23542370
($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)
2371+
$crate::get_route_and_payment_hash!(
2372+
$send_node,
2373+
$recv_node,
2374+
$payment_params,
2375+
$recv_value,
2376+
None
2377+
)
23562378
}};
23572379
($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);
2380+
let mut route_params =
2381+
$crate::routing::router::RouteParameters::from_payment_params_and_value(
2382+
$payment_params,
2383+
$recv_value,
2384+
);
23592385
route_params.max_total_routing_fee_msat = $max_total_routing_fee_msat;
23602386
let (payment_preimage, payment_hash, payment_secret) =
2361-
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$recv_node, Some($recv_value), None);
2387+
$crate::ln::functional_test_utils::get_payment_preimage_hash(
2388+
&$recv_node,
2389+
Some($recv_value),
2390+
None,
2391+
);
23622392
let route = $crate::ln::functional_test_utils::get_route(&$send_node, &route_params);
23632393
(route.unwrap(), payment_hash, payment_preimage, payment_secret)
2364-
}}
2394+
}};
23652395
}
23662396

23672397
#[rustfmt::skip]
@@ -2480,12 +2510,22 @@ macro_rules! expect_payment_sent {
24802510
$crate::expect_payment_sent!($node, $expected_payment_preimage, None::<u64>, true)
24812511
};
24822512
($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)
2513+
$crate::expect_payment_sent!(
2514+
$node,
2515+
$expected_payment_preimage,
2516+
$expected_fee_msat_opt,
2517+
true
2518+
)
24842519
};
24852520
($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-
}
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+
};
24892529
}
24902530

24912531
#[macro_export]
@@ -2498,7 +2538,7 @@ macro_rules! expect_payment_path_successful {
24982538
$crate::events::Event::PaymentPathSuccessful { .. } => {},
24992539
_ => panic!("Unexpected event"),
25002540
}
2501-
}
2541+
};
25022542
}
25032543

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

0 commit comments

Comments
 (0)