Skip to content

Commit 26a2222

Browse files
committed
ln/fmt: clean up ugly formatting of do_test_trampoline_unblinded_receive
1 parent 8c9e01e commit 26a2222

File tree

2 files changed

+23
-36
lines changed

2 files changed

+23
-36
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,17 +2290,14 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
22902290

22912291
let chanmon_cfgs = create_chanmon_cfgs(TOTAL_NODE_COUNT);
22922292
let node_cfgs = create_node_cfgs(TOTAL_NODE_COUNT, &chanmon_cfgs);
2293-
let node_chanmgrs =
2294-
create_node_chanmgrs(TOTAL_NODE_COUNT, &node_cfgs, &vec![None; TOTAL_NODE_COUNT]);
2293+
let user_cfgs = &vec![None; TOTAL_NODE_COUNT];
2294+
let node_chanmgrs = create_node_chanmgrs(TOTAL_NODE_COUNT, &node_cfgs, &user_cfgs);
22952295
let mut nodes = create_network(TOTAL_NODE_COUNT, &node_cfgs, &node_chanmgrs);
22962296

2297-
let (_, _, chan_id_alice_bob, _) =
2298-
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
2299-
let (_, _, chan_id_bob_carol, _) =
2300-
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0);
2297+
let alice_bob_chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
2298+
let bob_carol_chan = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0);
23012299

23022300
for i in 0..TOTAL_NODE_COUNT {
2303-
// connect all nodes' blocks
23042301
connect_blocks(
23052302
&nodes[i],
23062303
(TOTAL_NODE_COUNT as u32) * CHAN_CONFIRM_DEPTH + 1 - nodes[i].best_block_info().1,
@@ -2310,30 +2307,15 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
23102307
let bob_node_id = nodes[1].node().get_our_node_id();
23112308
let carol_node_id = nodes[2].node().get_our_node_id();
23122309

2313-
let alice_bob_scid = nodes[0]
2314-
.node()
2315-
.list_channels()
2316-
.iter()
2317-
.find(|c| c.channel_id == chan_id_alice_bob)
2318-
.unwrap()
2319-
.short_channel_id
2320-
.unwrap();
2321-
let bob_carol_scid = nodes[1]
2322-
.node()
2323-
.list_channels()
2324-
.iter()
2325-
.find(|c| c.channel_id == chan_id_bob_carol)
2326-
.unwrap()
2327-
.short_channel_id
2328-
.unwrap();
2310+
let alice_bob_scid = get_scid_from_channel_id(&nodes[0], alice_bob_chan.2);
2311+
let bob_carol_scid = get_scid_from_channel_id(&nodes[1], bob_carol_chan.2);
23292312

23302313
let amt_msat = 1000;
23312314
let (payment_preimage, payment_hash, payment_secret) =
23322315
get_payment_preimage_hash(&nodes[2], Some(amt_msat), None);
23332316
let route = Route {
23342317
paths: vec![Path {
23352318
hops: vec![
2336-
// Bob
23372319
RouteHop {
23382320
pubkey: bob_node_id,
23392321
node_features: NodeFeatures::empty(),
@@ -2343,7 +2325,6 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
23432325
cltv_expiry_delta: 48,
23442326
maybe_announced_channel: false,
23452327
},
2346-
// Carol
23472328
RouteHop {
23482329
pubkey: carol_node_id,
23492330
node_features: NodeFeatures::empty(),
@@ -2355,15 +2336,12 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
23552336
},
23562337
],
23572338
blinded_tail: Some(BlindedTail {
2358-
trampoline_hops: vec![
2359-
// Carol
2360-
TrampolineHop {
2361-
pubkey: carol_node_id,
2362-
node_features: Features::empty(),
2363-
fee_msat: amt_msat,
2364-
cltv_expiry_delta: 24,
2365-
},
2366-
],
2339+
trampoline_hops: vec![TrampolineHop {
2340+
pubkey: carol_node_id,
2341+
node_features: Features::empty(),
2342+
fee_msat: amt_msat,
2343+
cltv_expiry_delta: 24,
2344+
}],
23672345
// The blinded path data is unused because we replace the onion of the last hop
23682346
hops: vec![BlindedHop {
23692347
blinded_node_id: PublicKey::from_slice(&[2; 33]).unwrap(),
@@ -2460,8 +2438,7 @@ fn do_test_trampoline_unblinded_receive(success: bool) {
24602438

24612439
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
24622440
assert_eq!(events.len(), 1);
2463-
let mut first_message_event =
2464-
remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
2441+
let mut first_message_event = remove_first_msg_event_to_node(&bob_node_id, &mut events);
24652442
let mut update_message = match first_message_event {
24662443
MessageSendEvent::UpdateHTLCs { ref mut updates, .. } => {
24672444
assert_eq!(updates.update_add_htlcs.len(), 1);

lightning/src/ln/functional_test_utils.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5526,3 +5526,13 @@ pub fn create_batch_channel_funding<'a, 'b, 'c>(
55265526
}
55275527
return (tx, funding_created_msgs);
55285528
}
5529+
5530+
pub fn get_scid_from_channel_id<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, channel_id: ChannelId) -> u64 {
5531+
node.node()
5532+
.list_channels()
5533+
.iter()
5534+
.find(|c| c.channel_id == channel_id)
5535+
.unwrap()
5536+
.short_channel_id
5537+
.unwrap()
5538+
}

0 commit comments

Comments
 (0)