Skip to content

Commit a107ca2

Browse files
committed
Drop useless vec! macro calls
`clippy` now complains about more instances of useless `vec!`s, so we drop them here. Backport of 3c1159c
1 parent df1f0d2 commit a107ca2

File tree

6 files changed

+35
-33
lines changed

6 files changed

+35
-33
lines changed

lightning/src/blinded_path/payment.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ mod tests {
869869
// Taken from the spec example for aggregating blinded payment info. See
870870
// https://github.com/lightning/bolts/blob/master/proposals/route-blinding.md#blinded-payments
871871
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
872-
let intermediate_nodes = vec![
872+
let intermediate_nodes = [
873873
PaymentForwardNode {
874874
node_id: dummy_pk,
875875
tlvs: ForwardTlvs {
@@ -944,7 +944,7 @@ mod tests {
944944
// If no hops charge fees, the htlc_minimum_msat should just be the maximum htlc_minimum_msat
945945
// along the path.
946946
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
947-
let intermediate_nodes = vec![
947+
let intermediate_nodes = [
948948
PaymentForwardNode {
949949
node_id: dummy_pk,
950950
tlvs: ForwardTlvs {
@@ -1003,7 +1003,7 @@ mod tests {
10031003
// Create a path with varying fees and htlc_mins, and make sure htlc_minimum_msat ends up as the
10041004
// max (htlc_min - following_fees) along the path.
10051005
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
1006-
let intermediate_nodes = vec![
1006+
let intermediate_nodes = [
10071007
PaymentForwardNode {
10081008
node_id: dummy_pk,
10091009
tlvs: ForwardTlvs {
@@ -1072,7 +1072,7 @@ mod tests {
10721072
// Create a path with varying fees and `htlc_maximum_msat`s, and make sure the aggregated max
10731073
// htlc ends up as the min (htlc_max - following_fees) along the path.
10741074
let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
1075-
let intermediate_nodes = vec![
1075+
let intermediate_nodes = [
10761076
PaymentForwardNode {
10771077
node_id: dummy_pk,
10781078
tlvs: ForwardTlvs {

lightning/src/crypto/chacha20.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ mod test {
354354
keystream: Vec<u8>,
355355
}
356356
// taken from http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04
357-
let test_vectors = vec![
357+
let test_vectors = [
358358
TestVector {
359359
key: [
360360
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -464,7 +464,7 @@ mod test {
464464
keystream: Vec<u8>,
465465
}
466466
// taken from http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04
467-
let test_vectors = vec![
467+
let test_vectors = [
468468
TestVector {
469469
key: [
470470
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

lightning/src/ln/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ fn do_test_forming_justice_tx_from_monitor_updates(broadcast_initial_commitment:
999999
let chanmon_cfgs = create_chanmon_cfgs(2);
10001000
let destination_script0 = chanmon_cfgs[0].keys_manager.get_destination_script([0; 32]).unwrap();
10011001
let destination_script1 = chanmon_cfgs[1].keys_manager.get_destination_script([0; 32]).unwrap();
1002-
let persisters = vec![
1002+
let persisters = [
10031003
WatchtowerPersister::new(destination_script0),
10041004
WatchtowerPersister::new(destination_script1),
10051005
];

lightning/src/offers/invoice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3012,7 +3012,7 @@ mod tests {
30123012
let secp_ctx = Secp256k1::new();
30133013
let payment_id = PaymentId([1; 32]);
30143014

3015-
let paths = vec![
3015+
let paths = [
30163016
BlindedMessagePath::from_blinded_path(
30173017
pubkey(40),
30183018
pubkey(41),

lightning/src/offers/refund.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ mod tests {
15871587
#[test]
15881588
fn parses_refund_with_optional_fields() {
15891589
let past_expiry = Duration::from_secs(0);
1590-
let paths = vec![
1590+
let paths = [
15911591
BlindedMessagePath::from_blinded_path(
15921592
pubkey(40),
15931593
pubkey(41),

lightning/src/routing/router.rs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,7 @@ mod tests {
40544054

40554055
// Simple route to 2 via 1
40564056

4057-
let our_chans = vec![get_channel_details(Some(2), our_id, InitFeatures::from_le_bytes(vec![0b11]), 100000)];
4057+
let our_chans = [get_channel_details(Some(2), our_id, InitFeatures::from_le_bytes(vec![0b11]), 100000)];
40584058

40594059
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100);
40604060
if let Err(err) = get_route(&our_id,
@@ -4473,7 +4473,7 @@ mod tests {
44734473
} else { panic!(); }
44744474

44754475
// If we specify a channel to node7, that overrides our local channel view and that gets used
4476-
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
4476+
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
44774477
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
44784478
route_params.payment_params.max_path_length = 2;
44794479
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
@@ -4521,7 +4521,7 @@ mod tests {
45214521
} else { panic!(); }
45224522

45234523
// If we specify a channel to node7, that overrides our local channel view and that gets used
4524-
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
4524+
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
45254525
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
45264526
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
45274527
Some(&our_chans.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
@@ -4586,7 +4586,7 @@ mod tests {
45864586
// If we specify a channel to node7, that overrides our local channel view and that gets used
45874587
let payment_params = PaymentParameters::from_node_id(nodes[2], 42);
45884588
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 100);
4589-
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
4589+
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
45904590
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
45914591
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
45924592
Some(&our_chans.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
@@ -5137,7 +5137,7 @@ mod tests {
51375137
let random_seed_bytes = [42; 32];
51385138

51395139
// Simple test with outbound channel to 4 to test that last_hops and first_hops connect
5140-
let our_chans = vec![get_channel_details(Some(42), nodes[3].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
5140+
let our_chans = [get_channel_details(Some(42), nodes[3].clone(), InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
51415141
let mut last_hops = last_hops(&nodes);
51425142
let payment_params = PaymentParameters::from_node_id(nodes[6], 42)
51435143
.with_route_hints(last_hops.clone()).unwrap();
@@ -5265,7 +5265,7 @@ mod tests {
52655265
htlc_maximum_msat: last_hop_htlc_max,
52665266
}]);
52675267
let payment_params = PaymentParameters::from_node_id(target_node_id, 42).with_route_hints(vec![last_hops]).unwrap();
5268-
let our_chans = vec![get_channel_details(Some(42), middle_node_id, InitFeatures::from_le_bytes(vec![0b11]), outbound_capacity_msat)];
5268+
let our_chans = [get_channel_details(Some(42), middle_node_id, InitFeatures::from_le_bytes(vec![0b11]), outbound_capacity_msat)];
52695269
let scorer = ln_test_utils::TestScorer::new();
52705270
let random_seed_bytes = [42; 32];
52715271
let logger = ln_test_utils::TestLogger::new();
@@ -5442,7 +5442,7 @@ mod tests {
54425442
});
54435443

54445444
// Now, limit the first_hop by the next_outbound_htlc_limit_msat of 200_000 sats.
5445-
let our_chans = vec![get_channel_details(Some(42), nodes[0].clone(), InitFeatures::from_le_bytes(vec![0b11]), 200_000_000)];
5445+
let our_chans = [get_channel_details(Some(42), nodes[0].clone(), InitFeatures::from_le_bytes(vec![0b11]), 200_000_000)];
54465446

54475447
{
54485448
// Attempt to route more than available results in a failure.
@@ -7827,7 +7827,7 @@ mod tests {
78277827

78287828
let our_node_id = ln_test_utils::pubkey(42);
78297829
let intermed_node_id = ln_test_utils::pubkey(43);
7830-
let first_hop = vec![get_channel_details(Some(42), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)];
7830+
let first_hop = [get_channel_details(Some(42), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)];
78317831

78327832
let amt_msat = 900_000;
78337833
let max_htlc_msat = 500_000;
@@ -7874,7 +7874,7 @@ mod tests {
78747874

78757875
// Re-run but with two first hop channels connected to the same route hint peers that must be
78767876
// split between.
7877-
let first_hops = vec![
7877+
let first_hops = [
78787878
get_channel_details(Some(42), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), amt_msat - 10),
78797879
get_channel_details(Some(43), intermed_node_id, InitFeatures::from_le_bytes(vec![0b11]), amt_msat - 10),
78807880
];
@@ -8286,8 +8286,9 @@ mod tests {
82868286
fee_proportional_millionths: 0,
82878287
excess_data: Vec::new()
82888288
});
8289-
let first_hops = vec![
8290-
get_channel_details(Some(1), nodes[1], InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)];
8289+
let first_hops = [
8290+
get_channel_details(Some(1), nodes[1], InitFeatures::from_le_bytes(vec![0b11]), 10_000_000)
8291+
];
82918292

82928293
let blinded_payinfo = BlindedPayInfo {
82938294
fee_base_msat: 1000,
@@ -8347,9 +8348,10 @@ mod tests {
83478348
// Values are taken from the fuzz input that uncovered this panic.
83488349
let amt_msat = 21_7020_5185_1403_2640;
83498350
let (_, _, _, nodes) = get_nodes(&secp_ctx);
8350-
let first_hops = vec![
8351+
let first_hops = [
83518352
get_channel_details(Some(1), nodes[1], channelmanager::provided_init_features(&config),
8352-
18446744073709551615)];
8353+
18446744073709551615),
8354+
];
83538355

83548356
let blinded_payinfo = BlindedPayInfo {
83558357
fee_base_msat: 5046_2720,
@@ -8493,7 +8495,7 @@ mod tests {
84938495
let amt_msat = 7_4009_8048;
84948496
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
84958497
let first_hop_outbound_capacity = 2_7345_2000;
8496-
let first_hops = vec![get_channel_details(
8498+
let first_hops = [get_channel_details(
84978499
Some(200), nodes[0], channelmanager::provided_init_features(&config),
84988500
first_hop_outbound_capacity
84998501
)];
@@ -8566,7 +8568,7 @@ mod tests {
85668568
// Values are taken from the fuzz input that uncovered this panic.
85678569
let amt_msat = 52_4288;
85688570
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
8569-
let first_hops = vec![get_channel_details(
8571+
let first_hops = [get_channel_details(
85708572
Some(161), nodes[0], channelmanager::provided_init_features(&config), 486_4000
85718573
), get_channel_details(
85728574
Some(122), nodes[0], channelmanager::provided_init_features(&config), 179_5000
@@ -8641,7 +8643,7 @@ mod tests {
86418643
// Values are taken from the fuzz input that uncovered this panic.
86428644
let amt_msat = 7_4009_8048;
86438645
let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
8644-
let first_hops = vec![get_channel_details(
8646+
let first_hops = [get_channel_details(
86458647
Some(200), nodes[0], channelmanager::provided_init_features(&config), 2_7345_2000
86468648
)];
86478649

@@ -8705,7 +8707,7 @@ mod tests {
87058707
// Values are taken from the fuzz input that uncovered this panic.
87068708
let amt_msat = 562_0000;
87078709
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
8708-
let first_hops = vec![
8710+
let first_hops = [
87098711
get_channel_details(
87108712
Some(83), nodes[0], channelmanager::provided_init_features(&config), 2199_0000,
87118713
),
@@ -8849,9 +8851,8 @@ mod tests {
88498851

88508852
// First create an insufficient first hop for channel with SCID 1 and check we'd use the
88518853
// route hint.
8852-
let first_hop = get_channel_details(Some(1), nodes[0],
8853-
channelmanager::provided_init_features(&config), 999_999);
8854-
let first_hops = vec![first_hop];
8854+
let first_hops = [get_channel_details(Some(1), nodes[0],
8855+
channelmanager::provided_init_features(&config), 999_999)];
88558856

88568857
let route = get_route(&our_node_id, &route_params.clone(), &network_graph.read_only(),
88578858
Some(&first_hops.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
@@ -8867,7 +8868,7 @@ mod tests {
88678868
// for a first hop channel.
88688869
let mut first_hop = get_channel_details(Some(1), nodes[0], channelmanager::provided_init_features(&config), 999_999);
88698870
first_hop.outbound_scid_alias = Some(44);
8870-
let first_hops = vec![first_hop];
8871+
let first_hops = [first_hop];
88718872

88728873
let route_res = get_route(&our_node_id, &route_params.clone(), &network_graph.read_only(),
88738874
Some(&first_hops.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
@@ -8879,7 +8880,7 @@ mod tests {
88798880
let mut first_hop = get_channel_details(Some(1), nodes[0],
88808881
channelmanager::provided_init_features(&config), 10_000_000);
88818882
first_hop.outbound_scid_alias = Some(44);
8882-
let first_hops = vec![first_hop];
8883+
let first_hops = [first_hop];
88838884

88848885
let route = get_route(&our_node_id, &route_params.clone(), &network_graph.read_only(),
88858886
Some(&first_hops.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
@@ -9002,8 +9003,9 @@ mod tests {
90029003
let amt_msat = 1_000_000;
90039004
let dest_node_id = nodes[1];
90049005

9005-
let first_hop = get_channel_details(Some(1), nodes[0], channelmanager::provided_init_features(&config), 10_000_000);
9006-
let first_hops = vec![first_hop];
9006+
let first_hops = [
9007+
get_channel_details(Some(1), nodes[0], channelmanager::provided_init_features(&config), 10_000_000),
9008+
];
90079009

90089010
let route_hint = RouteHint(vec![RouteHintHop {
90099011
src_node_id: our_node_id,

0 commit comments

Comments
 (0)