Skip to content

Commit 3a8863f

Browse files
committed
Address clippy lints in lightning test code
In a coming commit we'll enable `clippy` linting in our test code. Here we prepare for this by addressing the lints we'll enforce in test codein the `lightning` crate.
1 parent 6f7e0c1 commit 3a8863f

16 files changed

+92
-95
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5598,7 +5598,7 @@ mod tests {
55985598
// and provides the claim preimages for the two pending HTLCs. The first update generates
55995599
// an error, but the point of this test is to ensure the later updates are still applied.
56005600
let monitor_updates = nodes[1].chain_monitor.monitor_updates.lock().unwrap();
5601-
let mut replay_update = monitor_updates.get(&channel.2).unwrap().iter().rev().next().unwrap().clone();
5601+
let mut replay_update = monitor_updates.get(&channel.2).unwrap().iter().next_back().unwrap().clone();
56025602
assert_eq!(replay_update.updates.len(), 1);
56035603
if let ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { .. } = replay_update.updates[0] {
56045604
} else { panic!(); }
@@ -5736,7 +5736,7 @@ mod tests {
57365736
let nondust_htlcs = dummy_commitment_tx.nondust_htlcs();
57375737

57385738
monitor.provide_latest_holder_commitment_tx(dummy_commitment_tx.clone(),
5739-
nondust_htlcs.into_iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect());
5739+
nondust_htlcs.iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect());
57405740
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"1").to_byte_array()),
57415741
preimages_slice_to_htlc_outputs!(preimages[5..15]), 281474976710655, dummy_key, &logger);
57425742
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"2").to_byte_array()),
@@ -5776,7 +5776,7 @@ mod tests {
57765776
// These HTLCs now have their output indices assigned
57775777
let nondust_htlcs = dummy_commitment_tx.nondust_htlcs();
57785778
monitor.provide_latest_holder_commitment_tx(dummy_commitment_tx.clone(),
5779-
nondust_htlcs.into_iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect());
5779+
nondust_htlcs.iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect());
57805780
secret[0..32].clone_from_slice(&<Vec<u8>>::from_hex("2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8").unwrap());
57815781
monitor.provide_secret(281474976710653, secret.clone()).unwrap();
57825782
assert_eq!(monitor.inner.lock().unwrap().payment_preimages.len(), 12);
@@ -5789,7 +5789,7 @@ mod tests {
57895789
// These HTLCs now have their output indices assigned
57905790
let nondust_htlcs = dummy_commitment_tx.nondust_htlcs();
57915791
monitor.provide_latest_holder_commitment_tx(dummy_commitment_tx.clone(),
5792-
nondust_htlcs.into_iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect());
5792+
nondust_htlcs.iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect());
57935793
secret[0..32].clone_from_slice(&<Vec<u8>>::from_hex("27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116").unwrap());
57945794
monitor.provide_secret(281474976710652, secret.clone()).unwrap();
57955795
assert_eq!(monitor.inner.lock().unwrap().payment_preimages.len(), 5);

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn mpp_to_one_hop_blinded_path() {
207207
create_announced_chan_between_nodes(&nodes, 0, 1);
208208
create_announced_chan_between_nodes(&nodes, 0, 2);
209209
let chan_upd_1_3 = create_announced_chan_between_nodes(&nodes, 1, 3).0.contents;
210-
create_announced_chan_between_nodes(&nodes, 2, 3).0.contents;
210+
create_announced_chan_between_nodes(&nodes, 2, 3);
211211

212212
// Ensure all nodes start at the same height.
213213
connect_blocks(&nodes[0], 4*CHAN_CONFIRM_DEPTH + 1 - nodes[0].best_block_info().1);
@@ -1976,7 +1976,7 @@ fn test_trampoline_inbound_payment_decoding() {
19761976
&carol_update_add, &carol_node_signer, &logger, &secp_ctx
19771977
).unwrap_or_else(|_| panic!());
19781978

1979-
let _carol_trampoline_update_add = if let onion_utils::Hop::TrampolineForward { next_trampoline_hop_data, .. } = carol_peeled_onion {
1979+
if let onion_utils::Hop::TrampolineForward { next_trampoline_hop_data, .. } = carol_peeled_onion {
19801980
assert_eq!(next_trampoline_hop_data.next_trampoline, dave_node_id);
19811981
} else {
19821982
panic!();

lightning/src/ln/functional_test_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,9 @@ macro_rules! unwrap_send_err {
10891089
let events = $node.node.get_and_clear_pending_events();
10901090
assert!(events.len() == 2);
10911091
match &events[0] {
1092-
crate::events::Event::PaymentPathFailed { failure, .. } => {
1092+
$crate::events::Event::PaymentPathFailed { failure, .. } => {
10931093
match failure {
1094-
crate::events::PathFailure::InitialSend { err } => {
1094+
$crate::events::PathFailure::InitialSend { err } => {
10951095
match err {
10961096
$type => { $check },
10971097
_ => panic!()
@@ -1103,7 +1103,7 @@ macro_rules! unwrap_send_err {
11031103
_ => panic!()
11041104
}
11051105
match &events[1] {
1106-
crate::events::Event::PaymentFailed { .. } => {},
1106+
$crate::events::Event::PaymentFailed { .. } => {},
11071107
_ => panic!()
11081108
}
11091109
}
@@ -2203,7 +2203,7 @@ macro_rules! get_payment_preimage_hash {
22032203
get_payment_preimage_hash!($dest_node, None)
22042204
};
22052205
($dest_node: expr, $min_value_msat: expr) => {
2206-
crate::get_payment_preimage_hash!($dest_node, $min_value_msat, None)
2206+
$crate::get_payment_preimage_hash!($dest_node, $min_value_msat, None)
22072207
};
22082208
($dest_node: expr, $min_value_msat: expr, $min_final_cltv_expiry_delta: expr) => {
22092209
$crate::ln::functional_test_utils::get_payment_preimage_hash(&$dest_node, $min_value_msat, $min_final_cltv_expiry_delta)

lightning/src/ln/functional_tests.rs

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -516,34 +516,35 @@ pub fn fake_network_test() {
516516
send_payment(&nodes[1], &[&nodes[3]], 8000000);
517517

518518
// Do some rebalance loop payments, simultaneously
519-
let mut hops = Vec::with_capacity(3);
520-
hops.push(RouteHop {
521-
pubkey: node_c_id,
522-
node_features: NodeFeatures::empty(),
523-
short_channel_id: chan_2.0.contents.short_channel_id,
524-
channel_features: ChannelFeatures::empty(),
525-
fee_msat: 0,
526-
cltv_expiry_delta: chan_3.0.contents.cltv_expiry_delta as u32,
527-
maybe_announced_channel: true,
528-
});
529-
hops.push(RouteHop {
530-
pubkey: node_d_id,
531-
node_features: NodeFeatures::empty(),
532-
short_channel_id: chan_3.0.contents.short_channel_id,
533-
channel_features: ChannelFeatures::empty(),
534-
fee_msat: 0,
535-
cltv_expiry_delta: chan_4.1.contents.cltv_expiry_delta as u32,
536-
maybe_announced_channel: true,
537-
});
538-
hops.push(RouteHop {
539-
pubkey: node_b_id,
540-
node_features: nodes[1].node.node_features(),
541-
short_channel_id: chan_4.0.contents.short_channel_id,
542-
channel_features: nodes[1].node.channel_features(),
543-
fee_msat: 1000000,
544-
cltv_expiry_delta: TEST_FINAL_CLTV,
545-
maybe_announced_channel: true,
546-
});
519+
let mut hops = vec![
520+
RouteHop {
521+
pubkey: node_c_id,
522+
node_features: NodeFeatures::empty(),
523+
short_channel_id: chan_2.0.contents.short_channel_id,
524+
channel_features: ChannelFeatures::empty(),
525+
fee_msat: 0,
526+
cltv_expiry_delta: chan_3.0.contents.cltv_expiry_delta as u32,
527+
maybe_announced_channel: true,
528+
},
529+
RouteHop {
530+
pubkey: node_d_id,
531+
node_features: NodeFeatures::empty(),
532+
short_channel_id: chan_3.0.contents.short_channel_id,
533+
channel_features: ChannelFeatures::empty(),
534+
fee_msat: 0,
535+
cltv_expiry_delta: chan_4.1.contents.cltv_expiry_delta as u32,
536+
maybe_announced_channel: true,
537+
},
538+
RouteHop {
539+
pubkey: node_b_id,
540+
node_features: nodes[1].node.node_features(),
541+
short_channel_id: chan_4.0.contents.short_channel_id,
542+
channel_features: nodes[1].node.channel_features(),
543+
fee_msat: 1000000,
544+
cltv_expiry_delta: TEST_FINAL_CLTV,
545+
maybe_announced_channel: true,
546+
},
547+
];
547548
hops[1].fee_msat = chan_4.1.contents.fee_base_msat as u64
548549
+ chan_4.1.contents.fee_proportional_millionths as u64 * hops[2].fee_msat as u64 / 1000000;
549550
hops[0].fee_msat = chan_3.0.contents.fee_base_msat as u64
@@ -559,34 +560,35 @@ pub fn fake_network_test() {
559560
let path: &[_] = &[&nodes[2], &nodes[3], &nodes[1]];
560561
let payment_preimage_1 = send_along_route(&nodes[1], route, path, 1000000).0;
561562

562-
let mut hops = Vec::with_capacity(3);
563-
hops.push(RouteHop {
564-
pubkey: node_d_id,
565-
node_features: NodeFeatures::empty(),
566-
short_channel_id: chan_4.0.contents.short_channel_id,
567-
channel_features: ChannelFeatures::empty(),
568-
fee_msat: 0,
569-
cltv_expiry_delta: chan_3.1.contents.cltv_expiry_delta as u32,
570-
maybe_announced_channel: true,
571-
});
572-
hops.push(RouteHop {
573-
pubkey: node_c_id,
574-
node_features: NodeFeatures::empty(),
575-
short_channel_id: chan_3.0.contents.short_channel_id,
576-
channel_features: ChannelFeatures::empty(),
577-
fee_msat: 0,
578-
cltv_expiry_delta: chan_2.1.contents.cltv_expiry_delta as u32,
579-
maybe_announced_channel: true,
580-
});
581-
hops.push(RouteHop {
582-
pubkey: node_b_id,
583-
node_features: nodes[1].node.node_features(),
584-
short_channel_id: chan_2.0.contents.short_channel_id,
585-
channel_features: nodes[1].node.channel_features(),
586-
fee_msat: 1000000,
587-
cltv_expiry_delta: TEST_FINAL_CLTV,
588-
maybe_announced_channel: true,
589-
});
563+
let mut hops = vec![
564+
RouteHop {
565+
pubkey: node_d_id,
566+
node_features: NodeFeatures::empty(),
567+
short_channel_id: chan_4.0.contents.short_channel_id,
568+
channel_features: ChannelFeatures::empty(),
569+
fee_msat: 0,
570+
cltv_expiry_delta: chan_3.1.contents.cltv_expiry_delta as u32,
571+
maybe_announced_channel: true,
572+
},
573+
RouteHop {
574+
pubkey: node_c_id,
575+
node_features: NodeFeatures::empty(),
576+
short_channel_id: chan_3.0.contents.short_channel_id,
577+
channel_features: ChannelFeatures::empty(),
578+
fee_msat: 0,
579+
cltv_expiry_delta: chan_2.1.contents.cltv_expiry_delta as u32,
580+
maybe_announced_channel: true,
581+
},
582+
RouteHop {
583+
pubkey: node_b_id,
584+
node_features: nodes[1].node.node_features(),
585+
short_channel_id: chan_2.0.contents.short_channel_id,
586+
channel_features: nodes[1].node.channel_features(),
587+
fee_msat: 1000000,
588+
cltv_expiry_delta: TEST_FINAL_CLTV,
589+
maybe_announced_channel: true,
590+
},
591+
];
590592
hops[1].fee_msat = chan_2.1.contents.fee_base_msat as u64
591593
+ chan_2.1.contents.fee_proportional_millionths as u64 * hops[2].fee_msat as u64 / 1000000;
592594
hops[0].fee_msat = chan_3.1.contents.fee_base_msat as u64
@@ -1498,9 +1500,8 @@ pub fn claim_htlc_outputs() {
14981500

14991501
// The ChannelMonitor should claim the accepted HTLC output separately from the offered
15001502
// HTLC and to_self outputs.
1501-
let accepted_claim = node_txn.iter().filter(|tx| tx.input.len() == 1).next().unwrap();
1502-
let offered_to_self_claim =
1503-
node_txn.iter().filter(|tx| tx.input.len() == 2).next().unwrap();
1503+
let accepted_claim = node_txn.iter().find(|tx| tx.input.len() == 1).unwrap();
1504+
let offered_to_self_claim = node_txn.iter().find(|tx| tx.input.len() == 2).unwrap();
15041505
check_spends!(accepted_claim, revoked_local_txn[0]);
15051506
check_spends!(offered_to_self_claim, revoked_local_txn[0]);
15061507
assert_eq!(
@@ -1512,7 +1513,7 @@ pub fn claim_htlc_outputs() {
15121513
witness_lens.insert(offered_to_self_claim.input[0].witness.last().unwrap().len());
15131514
witness_lens.insert(offered_to_self_claim.input[1].witness.last().unwrap().len());
15141515
assert_eq!(witness_lens.len(), 2);
1515-
assert_eq!(*witness_lens.iter().skip(0).next().unwrap(), 77); // revoked to_local
1516+
assert_eq!(*witness_lens.iter().next().unwrap(), 77); // revoked to_local
15161517
assert_eq!(*witness_lens.iter().skip(1).next().unwrap(), OFFERED_HTLC_SCRIPT_WEIGHT);
15171518

15181519
// Finally, mine the penalty transaction and check that we get an HTLC failure after
@@ -7542,7 +7543,7 @@ pub fn test_manually_accept_inbound_channel_request() {
75427543
};
75437544
match &events[1] {
75447545
crate::events::Event::ChannelPending { counterparty_node_id, .. } => {
7545-
assert_eq!(*&node_b_id, *counterparty_node_id);
7546+
assert_eq!(node_b_id, *counterparty_node_id);
75467547
},
75477548
_ => panic!("Unexpected event"),
75487549
};
@@ -7959,7 +7960,7 @@ pub fn test_preimage_storage() {
79597960

79607961
let node_a_id = nodes[0].node.get_our_node_id();
79617962

7962-
create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
7963+
create_announced_chan_between_nodes(&nodes, 0, 1);
79637964

79647965
{
79657966
let (payment_hash, payment_secret) =
@@ -8002,7 +8003,7 @@ pub fn test_bad_secret_hash() {
80028003
let node_a_id = nodes[0].node.get_our_node_id();
80038004
let node_b_id = nodes[1].node.get_our_node_id();
80048005

8005-
create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
8006+
create_announced_chan_between_nodes(&nodes, 0, 1);
80068007

80078008
let random_hash = PaymentHash([42; 32]);
80088009
let random_secret = PaymentSecret([43; 32]);
@@ -8195,7 +8196,7 @@ pub fn test_concurrent_monitor_claim() {
81958196
send_payment(&nodes[0], &[&nodes[1]], 10_000_000);
81968197

81978198
// Route a HTLC from node 0 to node 1 (but don't settle)
8198-
route_payment(&nodes[0], &[&nodes[1]], 9_000_000).0;
8199+
route_payment(&nodes[0], &[&nodes[1]], 9_000_000);
81998200

82008201
// Copy ChainMonitor to simulate watchtower Alice and update block height her ChannelMonitor timeout HTLC onchain
82018202
let chain_source = test_utils::TestChainSource::new(Network::Testnet);
@@ -10088,7 +10089,7 @@ fn do_test_max_dust_htlc_exposure(
1008810089
}
1008910090
{
1009010091
let mut feerate_lock = chanmon_cfgs[0].fee_estimator.sat_per_kw.lock().unwrap();
10091-
*feerate_lock = *feerate_lock * 10;
10092+
*feerate_lock *= 10;
1009210093
}
1009310094
nodes[0].node.timer_tick_occurred();
1009410095
check_added_monitors(&nodes[0], 1);
@@ -11745,7 +11746,7 @@ pub fn test_funding_signed_event() {
1174511746
};
1174611747
match &events[1] {
1174711748
crate::events::Event::ChannelPending { counterparty_node_id, .. } => {
11748-
assert_eq!(*&node_b_id, *counterparty_node_id);
11749+
assert_eq!(node_b_id, *counterparty_node_id);
1174911750
},
1175011751
_ => panic!("Unexpected event"),
1175111752
};

lightning/src/ln/monitor_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
761761
// Confirm node B's claim for node A to remove that claim from the aggregated claim transaction.
762762
mine_transaction(&nodes[0], &b_broadcast_txn[0]);
763763
let a_broadcast_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
764-
let a_htlc_timeout_tx = a_broadcast_txn.into_iter().last().unwrap();
764+
let a_htlc_timeout_tx = a_broadcast_txn.into_iter().next_back().unwrap();
765765

766766
// Once the HTLC-Timeout transaction confirms, A will no longer consider the HTLC
767767
// "MaybeClaimable", but instead move it to "AwaitingConfirmations".

lightning/src/ln/msgs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4563,7 +4563,7 @@ mod tests {
45634563
}
45644564
if disable {
45654565
let flag = target_value.last_mut().unwrap();
4566-
*flag = *flag | 1 << 1;
4566+
*flag |= 1 << 1;
45674567
}
45684568
target_value
45694569
.append(&mut <Vec<u8>>::from_hex("009000000000000f42400000271000000014").unwrap());

lightning/src/ln/payment_tests.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ fn claimed_send_payment_idempotent() {
17471747
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
17481748
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
17491749

1750-
create_announced_chan_between_nodes(&nodes, 0, 1).2;
1750+
create_announced_chan_between_nodes(&nodes, 0, 1);
17511751

17521752
let (route, hash_b, preimage_b, second_payment_secret) =
17531753
get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
@@ -1830,7 +1830,7 @@ fn abandoned_send_payment_idempotent() {
18301830
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
18311831
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
18321832

1833-
create_announced_chan_between_nodes(&nodes, 0, 1).2;
1833+
create_announced_chan_between_nodes(&nodes, 0, 1);
18341834

18351835
let (route, hash_b, second_payment_preimage, second_payment_secret) =
18361836
get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
@@ -2434,14 +2434,14 @@ fn do_accept_underpaying_htlcs_config(num_mpp_parts: usize) {
24342434
assert_eq!(events.len(), 1);
24352435
match events[0] {
24362436
crate::events::Event::PaymentClaimable {
2437-
ref payment_hash,
2437+
payment_hash: pmt_hash,
24382438
ref purpose,
24392439
amount_msat,
24402440
counterparty_skimmed_fee_msat,
24412441
receiver_node_id,
24422442
..
24432443
} => {
2444-
assert_eq!(payment_hash, payment_hash);
2444+
assert_eq!(pmt_hash, payment_hash);
24452445
assert_eq!(amt_msat - skimmed_fee_msat * num_mpp_parts as u64, amount_msat);
24462446
assert_eq!(skimmed_fee_msat * num_mpp_parts as u64, counterparty_skimmed_fee_msat);
24472447
assert_eq!(node_c_id, receiver_node_id.unwrap());
@@ -3065,7 +3065,7 @@ fn fails_paying_after_rejected_by_payee() {
30653065
let node_a_id = nodes[0].node.get_our_node_id();
30663066
let node_b_id = nodes[1].node.get_our_node_id();
30673067

3068-
create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
3068+
create_announced_chan_between_nodes(&nodes, 0, 1);
30693069

30703070
// Marshall data to send the payment
30713071
let amt_msat = 20_000;
@@ -4159,7 +4159,6 @@ fn do_claim_from_closed_chan(fail_payment: bool) {
41594159
send_msgs.sort_by(|a, _| {
41604160
let a_node_id =
41614161
if let MessageSendEvent::UpdateHTLCs { node_id, .. } = a { node_id } else { panic!() };
4162-
let node_b_id = node_b_id;
41634162
if *a_node_id == node_b_id {
41644163
Ordering::Less
41654164
} else {

lightning/src/ln/priv_short_conf_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn test_routed_scid_alias() {
234234
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, Some(no_announce_cfg), None]);
235235
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
236236

237-
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000).2;
237+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000);
238238
let mut as_channel_ready = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000).0;
239239

240240
let last_hop = nodes[2].node.list_usable_channels();

lightning/src/onion_message/dns_resolution.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,7 @@ impl OMNameResolver {
459459
.filter_map(
460460
|rr| if let RR::Txt(txt) = rr { Some(txt.data.as_vec()) } else { None },
461461
)
462-
.filter_map(
463-
|data| if let Ok(s) = String::from_utf8(data) { Some(s) } else { None },
464-
)
462+
.filter_map(|data| String::from_utf8(data).ok())
465463
.filter(|data_string| data_string.len() > URI_PREFIX.len())
466464
.filter(|data_string| {
467465
data_string[..URI_PREFIX.len()].eq_ignore_ascii_case(URI_PREFIX)

lightning/src/onion_message/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ fn add_channel_to_graph(
361361

362362
fn pass_along_path(path: &Vec<MessengerNode>) {
363363
let mut prev_node = &path[0];
364-
for node in path.into_iter().skip(1) {
364+
for node in path.iter().skip(1) {
365365
let events = prev_node.messenger.release_pending_msgs();
366366
let onion_msg = {
367367
let msgs = events.get(&node.node_id).unwrap();

lightning/src/routing/gossip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4162,7 +4162,7 @@ pub(crate) mod tests {
41624162
fn displays_node_alias() {
41634163
let format_str_alias = |alias: &str| {
41644164
let mut bytes = [0u8; 32];
4165-
bytes[..alias.as_bytes().len()].copy_from_slice(alias.as_bytes());
4165+
bytes[..alias.len()].copy_from_slice(alias.as_bytes());
41664166
format!("{}", NodeAlias(bytes))
41674167
};
41684168

0 commit comments

Comments
 (0)