Skip to content

Commit 5507b92

Browse files
committed
Drop useless vec! macro calls
`clippy` now complains about more instances of useless `vec!`s, so we drop them here.
1 parent a8b990a commit 5507b92

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
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
@@ -3002,7 +3002,7 @@ mod tests {
30023002
let secp_ctx = Secp256k1::new();
30033003
let payment_id = PaymentId([1; 32]);
30043004

3005-
let paths = vec![
3005+
let paths = [
30063006
BlindedMessagePath::from_blinded_path(
30073007
pubkey(40),
30083008
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: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4053,7 +4053,7 @@ mod tests {
40534053

40544054
// Simple route to 2 via 1
40554055

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

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

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

45224522
// If we specify a channel to node7, that overrides our local channel view and that gets used
4523-
let our_chans = vec![get_channel_details(Some(42), nodes[7].clone(),
4523+
let our_chans = [get_channel_details(Some(42), nodes[7].clone(),
45244524
InitFeatures::from_le_bytes(vec![0b11]), 250_000_000)];
45254525
let route = get_route(&our_id, &route_params, &network_graph.read_only(),
45264526
Some(&our_chans.iter().collect::<Vec<_>>()), Arc::clone(&logger), &scorer,
@@ -5136,7 +5136,7 @@ mod tests {
51365136
let random_seed_bytes = [42; 32];
51375137

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

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

54465446
{
54475447
// Attempt to route more than available results in a failure.
@@ -7826,7 +7826,7 @@ mod tests {
78267826

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

78317831
let amt_msat = 900_000;
78327832
let max_htlc_msat = 500_000;
@@ -7873,7 +7873,7 @@ mod tests {
78737873

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

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

83538355
let blinded_payinfo = BlindedPayInfo {
83548356
fee_base_msat: 5046_2720,
@@ -8492,7 +8494,7 @@ mod tests {
84928494
let amt_msat = 7_4009_8048;
84938495
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
84948496
let first_hop_outbound_capacity = 2_7345_2000;
8495-
let first_hops = vec![get_channel_details(
8497+
let first_hops = [get_channel_details(
84968498
Some(200), nodes[0], channelmanager::provided_init_features(&config),
84978499
first_hop_outbound_capacity
84988500
)];
@@ -8640,7 +8642,7 @@ mod tests {
86408642
// Values are taken from the fuzz input that uncovered this panic.
86418643
let amt_msat = 7_4009_8048;
86428644
let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
8643-
let first_hops = vec![get_channel_details(
8645+
let first_hops = [get_channel_details(
86448646
Some(200), nodes[0], channelmanager::provided_init_features(&config), 2_7345_2000
86458647
)];
86468648

@@ -8704,7 +8706,7 @@ mod tests {
87048706
// Values are taken from the fuzz input that uncovered this panic.
87058707
let amt_msat = 562_0000;
87068708
let (_, our_id, _, nodes) = get_nodes(&secp_ctx);
8707-
let first_hops = vec![
8709+
let first_hops = [
87088710
get_channel_details(
87098711
Some(83), nodes[0], channelmanager::provided_init_features(&config), 2199_0000,
87108712
),
@@ -8848,9 +8850,8 @@ mod tests {
88488850

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

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

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

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

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

0 commit comments

Comments
 (0)