Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec committed Sep 26, 2024
1 parent 137f4f8 commit 78b994d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl ForkDetails {
#[cfg(test)]
mod tests {
use zksync_basic_types::{AccountTreeId, L1BatchNumber, H256};
use zksync_state::ReadStorage;
use zksync_state::interface::ReadStorage;
use zksync_types::{api::TransactionVariant, StorageKey};

use crate::config::cache::CacheConfig;
Expand Down
18 changes: 6 additions & 12 deletions src/http_fork_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl ForkSource for HttpForkSource {

let client = self.create_client();
block_on(async move { client.get_transaction_by_hash(hash).await })
.map(|maybe_transaction| {
.inspect(|maybe_transaction| {
if let Some(transaction) = &maybe_transaction {
self.cache
.write()
Expand All @@ -99,7 +99,6 @@ impl ForkSource for HttpForkSource {
)
});
}
maybe_transaction
})
.wrap_err("fork http client failed")
}
Expand Down Expand Up @@ -133,7 +132,7 @@ impl ForkSource for HttpForkSource {
let client = self.create_client();
block_on(async move { client.get_raw_block_transactions(block_number).await })
.wrap_err("fork http client failed")
.map(|transactions| {
.inspect(|transactions| {
if !transactions.is_empty() {
self.cache
.write()
Expand All @@ -147,7 +146,6 @@ impl ForkSource for HttpForkSource {
)
});
}
transactions
})
}

Expand All @@ -167,7 +165,7 @@ impl ForkSource for HttpForkSource {

let client = self.create_client();
block_on(async move { client.get_block_by_hash(hash, full_transactions).await })
.map(|block| {
.inspect(|block| {
if let Some(block) = &block {
self.cache
.write()
Expand All @@ -179,7 +177,6 @@ impl ForkSource for HttpForkSource {
)
});
}
block
})
.wrap_err("fork http client failed")
}
Expand Down Expand Up @@ -211,7 +208,7 @@ impl ForkSource for HttpForkSource {
.get_block_by_number(block_number, full_transactions)
.await
})
.map(|block| {
.inspect(|block| {
if let Some(block) = &block {
self.cache
.write()
Expand All @@ -225,7 +222,6 @@ impl ForkSource for HttpForkSource {
)
});
}
block
})
.wrap_err("fork http client failed")
}
Expand Down Expand Up @@ -313,7 +309,7 @@ impl ForkSource for HttpForkSource {

let client = self.create_client();
block_on(async move { client.get_bridge_contracts().await })
.map(|bridge_addresses| {
.inspect(|bridge_addresses| {
self.cache
.write()
.map(|mut guard| guard.set_bridge_addresses(bridge_addresses.clone()))
Expand All @@ -323,7 +319,6 @@ impl ForkSource for HttpForkSource {
err
)
});
bridge_addresses
})
.wrap_err("fork http client failed")
}
Expand All @@ -342,7 +337,7 @@ impl ForkSource for HttpForkSource {

let client = self.create_client();
block_on(async move { client.get_confirmed_tokens(from, limit).await })
.map(|confirmed_tokens| {
.inspect(|confirmed_tokens| {
self.cache
.write()
.map(|mut guard| {
Expand All @@ -354,7 +349,6 @@ impl ForkSource for HttpForkSource {
err
)
});
confirmed_tokens
})
.wrap_err("fork http client failed")
}
Expand Down
2 changes: 1 addition & 1 deletion src/node/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ mod tests {
);

let mut tx = L2Tx::new_signed(
deployed_address,
Some(deployed_address),
hex::decode("bbf55335").unwrap(), // keccak selector for "transact_retrieve1()"
Nonce(1),
Fee {
Expand Down
4 changes: 2 additions & 2 deletions src/node/in_memory_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ mod tests {
use std::str::FromStr;
use std::sync::{Arc, RwLock};
use zksync_basic_types::{Nonce, H256};
use zksync_state::ReadStorage;
use zksync_state::interface::ReadStorage;
use zksync_types::{api::BlockNumber, fee::Fee, l2::L2Tx, PackedEthSignature};

#[tokio::test]
Expand Down Expand Up @@ -563,7 +563,7 @@ mod tests {

// construct a tx
let mut tx = L2Tx::new(
Address::random(),
Some(Address::random()),
vec![],
Nonce(0),
Fee {
Expand Down
10 changes: 4 additions & 6 deletions src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ impl SignEthClient {
.get(url)
.send()
.await
.map_err(|err| {
self.on_reqwest_err(&err);
err
.inspect_err(|err| {
self.on_reqwest_err(err);
})?
.text()
.await
.map_err(|err| {
self.on_reqwest_err(&err);
err
.inspect_err(|err| {
self.on_reqwest_err(err);
})
}

Expand Down
6 changes: 4 additions & 2 deletions src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ impl TransactionBuilder {

pub fn build(&mut self) -> L2Tx {
let mut tx = L2Tx::new_signed(
Address::random(),
Some(Address::random()),
vec![],
Nonce(0),
Fee {
Expand Down Expand Up @@ -537,7 +537,7 @@ pub fn deploy_contract<T: ForkSource + std::fmt::Debug + Clone>(
.expect("failed encoding function data");

let mut tx = L2Tx::new_signed(
zksync_types::CONTRACT_DEPLOYER_ADDRESS,
Some(zksync_types::CONTRACT_DEPLOYER_ADDRESS),
data.to_vec(),
nonce,
Fee {
Expand All @@ -563,6 +563,7 @@ pub fn deploy_contract<T: ForkSource + std::fmt::Debug + Clone>(
#[derive(Debug, Default, Clone)]
pub struct LogBuilder {
block_number: U64,
block_timestamp: U64,
address: Option<H160>,
topics: Option<Vec<H256>>,
}
Expand Down Expand Up @@ -606,6 +607,7 @@ impl LogBuilder {
transaction_log_index: Default::default(),
log_type: Default::default(),
removed: Some(false),
block_timestamp: Some(self.block_timestamp),
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,7 @@ mod tests {
#[test]
fn test_utc_datetime_from_epoch_ms() {
let actual = utc_datetime_from_epoch_ms(1623931200000);
assert_eq!(
DateTime::<Utc>::from_naive_utc_and_offset(
chrono::NaiveDateTime::from_timestamp_opt(1623931200, 0).unwrap(),
Utc
),
actual
);
assert_eq!(DateTime::from_timestamp(1623931200, 0).unwrap(), actual);
}

#[test]
Expand Down

0 comments on commit 78b994d

Please sign in to comment.