Skip to content

Commit f46be2c

Browse files
committed
Address clippy lints in remaining tests
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 code in remaining crates.
1 parent 3a8863f commit f46be2c

File tree

6 files changed

+38
-40
lines changed

6 files changed

+38
-40
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ mod tests {
22552255
get_event!(nodes[1], Event::ChannelPending);
22562256
let msg_1 = get_event_msg!(nodes[1], MessageSendEvent::SendFundingSigned, node_0_id);
22572257
nodes[0].node.handle_funding_signed(node_1_id, &msg_1);
2258-
let _ = channel_pending_recv
2258+
channel_pending_recv
22592259
.recv_timeout(Duration::from_secs(EVENT_DEADLINE))
22602260
.expect("ChannelPending not handled within deadline");
22612261

lightning-invoice/src/de.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,37 +1025,38 @@ mod test {
10251025
fqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzq".as_bytes()
10261026
);
10271027

1028-
let mut expected = Vec::<RouteHintHop>::new();
1029-
expected.push(RouteHintHop {
1030-
src_node_id: PublicKey::from_slice(
1031-
&[
1032-
0x02u8, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4, 0x3c,
1033-
0x74, 0x43, 0x1f, 0x7c, 0xe7, 0x20, 0x46, 0x06, 0x0f, 0xcf, 0x7a, 0x95, 0xc3,
1034-
0x7e, 0x14, 0x8f, 0x78, 0xc7, 0x72, 0x55,
1035-
][..],
1036-
)
1037-
.unwrap(),
1038-
short_channel_id: 0x0102030405060708,
1039-
fees: RoutingFees { base_msat: 1, proportional_millionths: 20 },
1040-
cltv_expiry_delta: 3,
1041-
htlc_minimum_msat: None,
1042-
htlc_maximum_msat: None,
1043-
});
1044-
expected.push(RouteHintHop {
1045-
src_node_id: PublicKey::from_slice(
1046-
&[
1047-
0x03u8, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4, 0x3c,
1048-
0x74, 0x43, 0x1f, 0x7c, 0xe7, 0x20, 0x46, 0x06, 0x0f, 0xcf, 0x7a, 0x95, 0xc3,
1049-
0x7e, 0x14, 0x8f, 0x78, 0xc7, 0x72, 0x55,
1050-
][..],
1051-
)
1052-
.unwrap(),
1053-
short_channel_id: 0x030405060708090a,
1054-
fees: RoutingFees { base_msat: 2, proportional_millionths: 30 },
1055-
cltv_expiry_delta: 4,
1056-
htlc_minimum_msat: None,
1057-
htlc_maximum_msat: None,
1058-
});
1028+
let expected = vec![
1029+
RouteHintHop {
1030+
src_node_id: PublicKey::from_slice(
1031+
&[
1032+
0x02u8, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4,
1033+
0x3c, 0x74, 0x43, 0x1f, 0x7c, 0xe7, 0x20, 0x46, 0x06, 0x0f, 0xcf, 0x7a,
1034+
0x95, 0xc3, 0x7e, 0x14, 0x8f, 0x78, 0xc7, 0x72, 0x55,
1035+
][..],
1036+
)
1037+
.unwrap(),
1038+
short_channel_id: 0x0102030405060708,
1039+
fees: RoutingFees { base_msat: 1, proportional_millionths: 20 },
1040+
cltv_expiry_delta: 3,
1041+
htlc_minimum_msat: None,
1042+
htlc_maximum_msat: None,
1043+
},
1044+
RouteHintHop {
1045+
src_node_id: PublicKey::from_slice(
1046+
&[
1047+
0x03u8, 0x9e, 0x03, 0xa9, 0x01, 0xb8, 0x55, 0x34, 0xff, 0x1e, 0x92, 0xc4,
1048+
0x3c, 0x74, 0x43, 0x1f, 0x7c, 0xe7, 0x20, 0x46, 0x06, 0x0f, 0xcf, 0x7a,
1049+
0x95, 0xc3, 0x7e, 0x14, 0x8f, 0x78, 0xc7, 0x72, 0x55,
1050+
][..],
1051+
)
1052+
.unwrap(),
1053+
short_channel_id: 0x030405060708090a,
1054+
fees: RoutingFees { base_msat: 2, proportional_millionths: 30 },
1055+
cltv_expiry_delta: 4,
1056+
htlc_minimum_msat: None,
1057+
htlc_maximum_msat: None,
1058+
},
1059+
];
10591060

10601061
assert_eq!(PrivateRoute::from_base32(&input), Ok(PrivateRoute(RouteHint(expected))));
10611062

@@ -1316,7 +1317,7 @@ mod test {
13161317
"0001020304050607080900010203040506070809000102030405060708090102",
13171318
)
13181319
.unwrap();
1319-
let description = std::iter::repeat("A").take(639).collect::<String>();
1320+
let description = "A".repeat(639);
13201321
let fallback_addr = crate::Fallback::SegWitProgram {
13211322
version: bitcoin::WitnessVersion::V0,
13221323
program: vec![0; 32],

lightning-invoice/src/test_ser_de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn private_route() {
269269
use crate::{PrivateRoute, PublicKey, RouteHint, RouteHintHop, RoutingFees};
270270

271271
let private_route = PrivateRoute(RouteHint(vec![RouteHintHop {
272-
src_node_id: PublicKey::from_slice(&vec![2; 33]).unwrap(),
272+
src_node_id: PublicKey::from_slice(&[2; 33]).unwrap(),
273273
short_channel_id: 0x0102030405060708,
274274
fees: RoutingFees { base_msat: 1, proportional_millionths: 20 },
275275
cltv_expiry_delta: 3,

lightning-liquidity/src/tests/utils.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ pub fn to_compressed_pubkey(hex: &str) -> Option<PublicKey> {
4040
Some(bytes) => bytes,
4141
None => return None,
4242
};
43-
match PublicKey::from_slice(&data) {
44-
Ok(pk) => Some(pk),
45-
Err(_) => None,
46-
}
43+
PublicKey::from_slice(&data).ok()
4744
}
4845

4946
pub fn parse_pubkey(pubkey_str: &str) -> Result<PublicKey, io::Error> {

lightning-liquidity/tests/lsps0_integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn list_protocols_integration_test() {
5151
let client_handler = client_node.liquidity_manager.lsps0_client_handler();
5252
let client_node_id = client_node.channel_manager.get_our_node_id();
5353

54-
let _ = client_handler.list_protocols(&service_node_id);
54+
client_handler.list_protocols(&service_node_id);
5555
let list_protocols_request = get_lsps_message!(client_node, service_node_id);
5656

5757
service_node

lightning-persister/src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn do_read_write_remove_list_persist<K: KVStore + RefUnwindSafe>(kv_s
4646

4747
// Ensure we have no issue operating with primary_namespace/secondary_namespace/key being
4848
// KVSTORE_NAMESPACE_KEY_MAX_LEN
49-
let max_chars: String = std::iter::repeat('A').take(KVSTORE_NAMESPACE_KEY_MAX_LEN).collect();
49+
let max_chars = "A".repeat(KVSTORE_NAMESPACE_KEY_MAX_LEN);
5050
kv_store.write(&max_chars, &max_chars, &max_chars, &data).unwrap();
5151

5252
let listed_keys = kv_store.list(&max_chars, &max_chars).unwrap();

0 commit comments

Comments
 (0)