commit c0109078a74e73ae2015bfd13580392d3c843eac
parent cf984689d19c3a2f532ee0005dbcce19c87e59f3
Author: Antoine A <>
Date: Tue, 4 Jan 2022 13:59:17 +0100
clippy fix
Diffstat:
6 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/btc-wire/src/bin/test.rs b/btc-wire/src/bin/test.rs
@@ -226,13 +226,13 @@ pub fn main() {
.send(&wire_addr, &Amount::from_sat(294), false)
.unwrap();
wait_for_tx(&mut client_rpc, &mut reserve_rpc, &[send_id]);
- assert!(match wire_rpc.bounce(&send_id, &bounce_fee, &[]) {
+ assert!(matches!(
+ wire_rpc.bounce(&send_id, &bounce_fee, &[]),
Err(rpc::Error::RPC {
code: rpc::ErrorCode::RpcWalletInsufficientFunds,
- msg: _,
- }) => true,
- _ => false,
- });
+ ..
+ })
+ ));
});
runner.test("Bounce simple with metadata", || {
let before = client_rpc.get_balance().unwrap();
@@ -264,28 +264,26 @@ pub fn main() {
.send(&wire_addr, &Amount::from_sat(294), false)
.unwrap();
wait_for_tx(&mut client_rpc, &mut reserve_rpc, &[send_id]);
- assert!(
- match wire_rpc.bounce(&send_id, &bounce_fee, &[12, 34, 56]) {
- Err(rpc::Error::RPC {
- code: rpc::ErrorCode::RpcWalletError,
- ..
- }) => true,
- _ => false,
- }
- );
+ assert!(matches!(
+ wire_rpc.bounce(&send_id, &bounce_fee, &[12, 34, 56]),
+ Err(rpc::Error::RPC {
+ code: rpc::ErrorCode::RpcWalletError,
+ ..
+ })
+ ));
});
runner.test("Bounce too small amount", || {
let send_id = client_rpc
.send(&wire_addr, &(Amount::from_sat(294) + bounce_fee), false)
.unwrap();
wait_for_tx(&mut client_rpc, &mut reserve_rpc, &[send_id]);
- assert!(match wire_rpc.bounce(&send_id, &bounce_fee, &[]) {
+ assert!(matches!(
+ wire_rpc.bounce(&send_id, &bounce_fee, &[]),
Err(rpc::Error::RPC {
code: rpc::ErrorCode::RpcWalletInsufficientFunds,
..
- }) => true,
- _ => false,
- });
+ })
+ ));
});
runner.test("Bounce complex", || {
// Generate 6 new addresses
diff --git a/btc-wire/src/main.rs b/btc-wire/src/main.rs
@@ -102,7 +102,7 @@ fn worker(mut rpc: AutoReconnectRPC, mut db: AutoReconnectSql, config: &Config)
&[&(TxStatus::Sent as i16), &tx_id.as_ref(), &id],
)?;
let amount = btc_amount_to_taler_amount(&amount.to_signed().unwrap());
- info!(">> {} {} in {} to {}", amount, base32(&wtid), tx_id, addr);
+ info!(">> {} {} in {} to {}", amount, base32(wtid), tx_id, addr);
}
Err(e) => {
info!("sender: RPC - {}", e);
@@ -138,7 +138,7 @@ fn worker(mut rpc: AutoReconnectRPC, mut db: AutoReconnectSql, config: &Config)
let metadata = encode_info(&info);
fail_point("Skip send_op_return", 0.2)?;
- match rpc.bounce(&bounced, &fee, &metadata) {
+ match rpc.bounce(&bounced, fee, &metadata) {
Ok(it) => {
info!("|| {} in {}", &bounced, &it);
tx.execute(
@@ -184,7 +184,7 @@ fn worker(mut rpc: AutoReconnectRPC, mut db: AutoReconnectSql, config: &Config)
}
// Conflate all notifications
let mut iter = ntf.iter();
- while let Some(_) = iter.next()? {}
+ while iter.next()?.is_some() {}
}
// Sync chain
sync_chain(rpc, db, config)?;
diff --git a/btc-wire/src/segwit.rs b/btc-wire/src/segwit.rs
@@ -41,8 +41,8 @@ pub fn encode_segwit_key(hrp: &str, msg: &[u8; 32]) -> [String; 2] {
let split: (&[u8; 16], &[u8; 16]) =
(msg[..16].try_into().unwrap(), msg[16..].try_into().unwrap());
[
- encode_segwit_key_half(hrp, true, &magic_id, &split.0),
- encode_segwit_key_half(hrp, false, &magic_id, &split.1),
+ encode_segwit_key_half(hrp, true, &magic_id, split.0),
+ encode_segwit_key_half(hrp, false, &magic_id, split.1),
]
}
@@ -60,7 +60,7 @@ pub enum DecodeSegWitErr {
pub fn decode_segwit_msg(segwit_addrs: &[impl AsRef<str>]) -> Result<[u8; 32], DecodeSegWitErr> {
// Extract parts from every addresses
let decoded: Vec<(bool, [u8; 4], [u8; 16])> = segwit_addrs
- .into_iter()
+ .iter()
.filter_map(|addr| {
bech32::decode(addr.as_ref()).ok().and_then(|(_, wp, _)| {
// Skip version
diff --git a/taler-api/src/api_common.rs b/taler-api/src/api_common.rs
@@ -320,7 +320,7 @@ impl<'de, const L: usize> Deserialize<'de> for Base32<L> {
where
D: Deserializer<'de>,
{
- Ok(Base32::from_str(&String::deserialize(deserializer)?).map_err(D::Error::custom)?)
+ Base32::from_str(&String::deserialize(deserializer)?).map_err(D::Error::custom)
}
}
diff --git a/uri-pack/src/main.rs b/uri-pack/src/main.rs
@@ -1,3 +1,5 @@
+use std::cmp::Ordering;
+
use uri_pack::pack_uri;
fn main() {
@@ -17,12 +19,10 @@ fn main() {
let after = pack_uri(domain).unwrap().len();
before_len += before;
after_len += after;
- if before == after {
- same += 1;
- } else if before > after {
- smaller += 1;
- } else {
- bigger += 1;
+ match before.cmp(&after) {
+ Ordering::Less => smaller += 1,
+ Ordering::Equal => same += 1,
+ Ordering::Greater => bigger += 1,
}
}
let sum: u64 = ascii_counter.iter().sum();
diff --git a/wire-gateway/src/main.rs b/wire-gateway/src/main.rs
@@ -50,7 +50,7 @@ async fn main() {
cfg.host = Some(
config
.get_hosts()
- .into_iter()
+ .iter()
.map(|it| match it {
Host::Tcp(it) => it.to_string(),
#[cfg(target_os = "linux")]
@@ -249,8 +249,8 @@ async fn router(
.unexpected()?
}
"/history/incoming" => {
- assert_method(&parts, Method::GET)?;
- let params = history_params(&parts)?;
+ assert_method(parts, Method::GET)?;
+ let params = history_params(parts)?;
let filter = sql_history_filter(¶ms);
let db = state.pool.get().await.catch_code(
StatusCode::GATEWAY_TIMEOUT,
@@ -293,8 +293,8 @@ async fn router(
.unexpected()?
}
"/history/outgoing" => {
- assert_method(&parts, Method::GET)?;
- let params = history_params(&parts)?;
+ assert_method(parts, Method::GET)?;
+ let params = history_params(parts)?;
let filter = sql_history_filter(¶ms);
let db = state.pool.get().await.catch_code(