Skip to content

Commit

Permalink
bump cargo and fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
OBorce committed May 15, 2024
1 parent 1082dfa commit 46af2dd
Show file tree
Hide file tree
Showing 24 changed files with 639 additions and 607 deletions.
1,178 changes: 603 additions & 575 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions api-server/stack-test-suite/tests/v2/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@

use api_web_server::api::json_helpers::nft_issuance_data_to_json;
use common::{
chain::tokens::{make_token_id, NftIssuance, NftIssuanceV0, TokenId},
chain::tokens::{make_token_id, NftIssuance, TokenId},
primitives::H256,
};
use serialization::extras::non_empty_vec::DataOrNoVec;

use crate::DummyRPC;

Expand Down
1 change: 0 additions & 1 deletion api-server/storage-test-suite/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub async fn set_get<S: ApiServerStorage, Fut, F: Fn() -> Fut>(
seed_maker: Box<dyn Fn() -> Seed + Send>,
) -> Result<(), Failed>
where
S: ApiServerStorage,
Fut: Future<Output = S> + Send + 'static,
{
let seed = seed_maker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ pub trait ChainstateAccessor {
pub trait BlockInfo: Clone {
fn id(&self) -> Id<Block>;
fn parent_id(&self) -> Id<GenBlock>;
#[allow(dead_code)]
fn height(&self) -> BlockHeight;
fn chain_trust(&self) -> Uint256;
fn status(&self) -> BlockStatus;
Expand Down
1 change: 1 addition & 0 deletions chainstate/src/detail/orphan_blocks/orphans_refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub trait OrphanBlocksRef {
}

pub trait OrphanBlocksMut: OrphanBlocksRef {
#[allow(dead_code)]
fn clear(&mut self);
fn add_block(&mut self, block: WithId<Block>) -> Result<(), Box<OrphanAddError>>;
fn take_all_children_of(&mut self, block_id: &Id<GenBlock>) -> Vec<WithId<Block>>;
Expand Down
1 change: 1 addition & 0 deletions chainstate/storage/src/is_transaction_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.

/// Prevent more types from implementing the [crate::IsTransaction] trait
#[allow(dead_code)]
pub trait Seal {}

impl<'st, B: storage::Backend> Seal for crate::internal::StoreTxRo<'st, B> {}
Expand Down
2 changes: 1 addition & 1 deletion dns-server/src/crawler_p2p/crawler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ impl Crawler {
.iter_mut()
.filter(|(address, address_data)| {
address_data.connect_now(self.now)
&& self.banned_addresses.get(&address.as_bannable()).is_none()
&& !self.banned_addresses.contains_key(&address.as_bannable())
})
.choose_multiple(rng, MAX_CONNECTS_PER_HEARTBEAT);

Expand Down
3 changes: 3 additions & 0 deletions dns-server/src/crawler_p2p/crawler/tests/mock_crawler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ pub struct MockPeer {

#[derive(Debug)]
pub struct AddressUpdate {
#[allow(dead_code)]
pub address: SocketAddress,
#[allow(dead_code)]
pub old_state: AddressState,
#[allow(dead_code)]
pub new_state: AddressState,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub struct TestNode {

#[derive(Clone)]
pub struct MockStateRef {
#[allow(dead_code)]
pub crawler_mgr_config: CrawlerManagerConfig,
pub online: Arc<Mutex<BTreeMap<SocketAddress, TestNode>>>,
pub connected: Arc<Mutex<BTreeMap<SocketAddress, PeerId>>>,
Expand Down
5 changes: 1 addition & 4 deletions mempool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ enum StringOrUint {
}

impl<'de> serde::Deserialize<'de> for MempoolMaxSize {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::Error;

match StringOrUint::deserialize(deserializer)? {
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/peer_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ where

/// Checks if the peer is in active state
fn is_peer_connected(&self, peer_id: PeerId) -> bool {
self.peers.get(&peer_id).is_some()
self.peers.contains_key(&peer_id)
}

// Return an error if a connection to the specified address already exists and it prevents us
Expand Down
5 changes: 2 additions & 3 deletions p2p/src/peer_manager/peerdb/address_tables/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,10 @@ pub mod test_utils {

let non_colliding = tables.iter().enumerate().all(|(table_idx, table)| {
let (bucket_idx, bucket_pos) = table.bucket_coords(&addr);
idx_set.get(&(table_idx, bucket_idx, bucket_pos)).is_none()
!idx_set.contains(&(table_idx, bucket_idx, bucket_pos))
});

if non_colliding && (!in_distinct_addr_groups || addr_groups.get(&addr_group).is_none())
{
if non_colliding && (!in_distinct_addr_groups || !addr_groups.contains(&addr_group)) {
result.push(addr);

if result.len() == count {
Expand Down
3 changes: 2 additions & 1 deletion p2p/src/peer_manager/peerdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ impl<S: PeerDbStorage> PeerDb<S> {

/// Add a new peer address
pub fn peer_discovered(&mut self, address: SocketAddress) {
if self.addresses.get(&address).is_none() {
#[allow(clippy::map_entry)]
if !self.addresses.contains_key(&address) {
log::debug!("New address discovered: {}", address.to_string());

debug_assert!(
Expand Down
12 changes: 6 additions & 6 deletions p2p/src/peer_manager/tests/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ async fn connect_to_predefined_address_if_dns_seed_is_empty() {

let peer_mgr = peer_mgr_join_handle.await.unwrap();
let addresses: BTreeSet<_> = peer_mgr.peerdb().known_addresses().cloned().collect();
assert!(addresses.get(&predefined_peer_address).is_some());
assert!(addresses.contains(&predefined_peer_address));
}

// Configure the peer manager with a non-empty dns seed and a predefined peer address.
Expand Down Expand Up @@ -541,8 +541,8 @@ async fn dont_connect_to_predefined_address_if_dns_seed_is_non_empty() {
let peer_mgr = peer_mgr_join_handle.await.unwrap();
let addresses: BTreeSet<_> = peer_mgr.peerdb().known_addresses().cloned().collect();
// seeded_peer_address is in the db, but predefined_peer_address is not.
assert!(addresses.get(&seeded_peer_address).is_some());
assert!(addresses.get(&predefined_peer_address).is_none());
assert!(addresses.contains(&seeded_peer_address));
assert!(!addresses.contains(&predefined_peer_address));
}

// 1) Configure the peer manager with a non-empty dns seed and a predefined peer address.
Expand Down Expand Up @@ -616,7 +616,7 @@ async fn connect_to_predefined_address_if_dns_seed_returned_bogus_address() {
let peer_mgr = peer_mgr_join_handle.await.unwrap();
let addresses: BTreeSet<_> = peer_mgr.peerdb().known_addresses().cloned().collect();
// predefined_peer_address is in the db.
assert!(addresses.get(&predefined_peer_address).is_some());
assert!(addresses.contains(&predefined_peer_address));
}

// 1) Configure the peer manager with a non-empty dns seed and non-empty peerdb.
Expand Down Expand Up @@ -717,8 +717,8 @@ async fn dont_use_dns_seed_if_connections_exist() {
let peer_mgr = peer_mgr_join_handle.await.unwrap();
let addresses: BTreeSet<_> = peer_mgr.peerdb().known_addresses().cloned().collect();
// existing_address is in the db, but seeded_peer_address is not.
assert!(addresses.get(&existing_address).is_some());
assert!(addresses.get(&seeded_peer_address).is_none());
assert!(addresses.contains(&existing_address));
assert!(!addresses.contains(&seeded_peer_address));
}

async fn recv_command_advance_time(
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/peer_manager/tests/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ async fn inbound_connection_invalid_magic_noise() {
}

// try to connect to an address that no one listening on and verify it fails
async fn test_peer_manager_connect<T: NetworkingService>(
async fn test_peer_manager_connect<T>(
transport: T::Transport,
bind_addr: SocketAddress,
remote_addr: SocketAddress,
Expand Down
3 changes: 1 addition & 2 deletions p2p/src/sync/peer_v2/block_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ where
// Check that all the blocks are known and haven't been already requested.
// First check self.outgoing.blocks_queue
let already_requested_blocks: BTreeSet<_> = self.outgoing.blocks_queue.iter().collect();
let doubly_requested_id =
block_ids.iter().find(|id| already_requested_blocks.get(id).is_some());
let doubly_requested_id = block_ids.iter().find(|id| already_requested_blocks.contains(id));
if let Some(id) = doubly_requested_id {
return Err(P2pError::ProtocolError(
ProtocolError::DuplicatedBlockRequest(*id),
Expand Down
2 changes: 2 additions & 0 deletions p2p/src/tests/helpers/test_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ where
Transport: TransportSocket,
{
pub peer_mgr: PeerMgr<Transport>,
#[allow(dead_code)]
pub peer_mgr_error: P2pError,
#[allow(dead_code)]
pub sync_mgr_error: P2pError,
}

Expand Down
4 changes: 2 additions & 2 deletions script/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ pub fn run_script<'a, Ctx: Context>(
/// Some pubkeys may not have signatures to go with them.
fn check_multisig<'a, Ctx: Context>(
ctx: &Ctx,
mut sigs: impl Iterator<Item = &'a [u8]> + ExactSizeIterator,
mut pubkeys: impl Iterator<Item = &'a [u8]> + ExactSizeIterator,
mut sigs: impl ExactSizeIterator<Item = &'a [u8]>,
mut pubkeys: impl ExactSizeIterator<Item = &'a [u8]>,
subscript: &[u8],
codesep_idx: u32,
) -> crate::Result<bool> {
Expand Down
2 changes: 1 addition & 1 deletion utxo/src/storage/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl UtxosView for UtxosDBInMemoryImpl {
}

fn has_utxo(&self, outpoint: &UtxoOutPoint) -> Result<bool, Self::Error> {
Ok(self.store.get(outpoint).is_some())
Ok(self.store.contains_key(outpoint))
}

fn best_block_hash(&self) -> Result<Id<GenBlock>, Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion utxo/src/storage/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn utxo_and_undo_test(#[case] seed: Seed) {
let mut cache = UtxosCache::new(&db).unwrap();

// get the block tx inputs, and add them to the view.
block.transactions().iter().enumerate().for_each(|(_idx, tx)| {
block.transactions().iter().for_each(|tx| {
// use the undo to get the utxos
let undo = block_undo.tx_undos().get(&tx.transaction().get_id()).unwrap();
let undos = undo.inner();
Expand Down
2 changes: 1 addition & 1 deletion utxo/src/tests/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub trait UnwrapInfallible {
impl<T> UnwrapInfallible for Result<T, Infallible> {
type Output = T;
fn unwrap_infallible(self) -> Self::Output {
self.map_or_else(|inf| match inf {}, |x| x)
self.unwrap_or_else(|inf| match inf {})
}
}

Expand Down
8 changes: 4 additions & 4 deletions wallet/src/account/output_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ impl PoolData {
}

pub enum TokenCurrentSupplyState {
Fixed(Amount, Amount), // fixed to a certain amount
Lockable(Amount), // not known in advance but can be locked once at some point in time
Locked(Amount), // Locked
Unlimited(Amount), // limited only by the Amount data type
Fixed(Amount, Amount), // fixed to a certain amount
Lockable(Amount), // not known in advance but can be locked once at some point in time
Locked(#[allow(dead_code)] Amount), // Locked
Unlimited(Amount), // limited only by the Amount data type
}

impl From<TokenTotalSupply> for TokenCurrentSupplyState {
Expand Down
2 changes: 1 addition & 1 deletion wallet/src/account/utxo_selector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ fn select_coins_bnb(
// value. Adding any more UTXOs will be just burning the UTXO; it will go entirely to fees. Thus we aren't going to
// explore any more UTXOs to avoid burning money like that.
if curr_waste <= best_waste {
best_selection = curr_selection.clone();
best_selection.clone_from(&curr_selection);
best_waste = curr_waste;
}
true
Expand Down
1 change: 1 addition & 0 deletions wallet/wallet-cli-lib/tests/cli_test_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub struct CliTestFramework {
pub shutdown_trigger: ShutdownTrigger,
pub manager_task: ManagerJoinHandle,
pub test_root: TestRoot,
#[allow(dead_code)]
pub chain_config: Arc<ChainConfig>,
}

Expand Down

0 comments on commit 46af2dd

Please sign in to comment.