From ee70351751abe61da3bc9f3b52f2e47c839c2328 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 29 Apr 2024 15:25:53 +0200 Subject: [PATCH] test: rm redundant helper trait (#7962) --- .../testing-utils/src/genesis_allocator.rs | 20 ++++++++++--------- testing/testing-utils/src/lib.rs | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/testing/testing-utils/src/genesis_allocator.rs b/testing/testing-utils/src/genesis_allocator.rs index 33b7188d1..067f68343 100644 --- a/testing/testing-utils/src/genesis_allocator.rs +++ b/testing/testing-utils/src/genesis_allocator.rs @@ -7,7 +7,10 @@ use secp256k1::{ rand::{thread_rng, RngCore}, Keypair, Secp256k1, }; -use std::collections::{hash_map::Entry, BTreeMap, HashMap}; +use std::{ + collections::{hash_map::Entry, BTreeMap, HashMap}, + fmt, +}; /// This helps create a custom genesis alloc by making it easy to add funded accounts with known /// signers to the genesis block. @@ -37,19 +40,18 @@ use std::collections::{hash_map::Entry, BTreeMap, HashMap}; /// // Once you're done adding accounts, you can build the alloc. /// let alloc = allocator.build(); /// ``` -#[derive(Debug)] pub struct GenesisAllocator<'a> { /// The genesis alloc to be built. alloc: HashMap, /// The rng to use for generating key pairs. - rng: Box, + rng: Box, } impl<'a> GenesisAllocator<'a> { /// Initialize a new alloc builder with the provided rng. pub fn new_with_rng(rng: &'a mut R) -> Self where - R: RngCore + std::fmt::Debug, + R: RngCore, { Self { alloc: HashMap::default(), rng: Box::new(rng) } } @@ -197,8 +199,8 @@ impl Default for GenesisAllocator<'_> { } } -/// Helper trait that encapsulates [RngCore], and [Debug](std::fmt::Debug) to get around rules -/// for auto traits (Opt-in built-in traits). -trait RngDebug: RngCore + std::fmt::Debug {} - -impl RngDebug for T where T: RngCore + std::fmt::Debug {} +impl fmt::Debug for GenesisAllocator<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("GenesisAllocator").field("alloc", &self.alloc).finish_non_exhaustive() + } +} diff --git a/testing/testing-utils/src/lib.rs b/testing/testing-utils/src/lib.rs index 0cf98c6ff..27b54b19e 100644 --- a/testing/testing-utils/src/lib.rs +++ b/testing/testing-utils/src/lib.rs @@ -6,6 +6,7 @@ issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] pub mod genesis_allocator;