From 169af74d3d12e3daaa759f108adbd1d099b3fab4 Mon Sep 17 00:00:00 2001 From: mandreyel Date: Mon, 20 Mar 2023 17:03:27 +0400 Subject: [PATCH] fix clippy lints --- jsontests/src/state.rs | 16 ++++++++-------- jsontests/src/utils.rs | 6 +++--- jsontests/tests/state.rs | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/jsontests/src/state.rs b/jsontests/src/state.rs index e2d2f5f..760b8a1 100644 --- a/jsontests/src/state.rs +++ b/jsontests/src/state.rs @@ -23,15 +23,15 @@ impl Test { } pub fn unwrap_caller(&self) -> H160 { - let hash: H256 = self.0.transaction.secret.clone().unwrap().into(); + let hash: H256 = self.0.transaction.secret.unwrap().into(); let mut secret_key = [0; 32]; - secret_key.copy_from_slice(&hash.as_bytes()[..]); + secret_key.copy_from_slice(hash.as_bytes()); let secret = SecretKey::parse(&secret_key); let public = libsecp256k1::PublicKey::from_secret_key(&secret.unwrap()); let mut res = [0u8; 64]; res.copy_from_slice(&public.serialize()[1..65]); - H160::from(H256::from_slice(Keccak256::digest(&res).as_slice())) + H160::from(H256::from_slice(Keccak256::digest(res).as_slice())) } pub fn unwrap_to_vicinity(&self, spec: &ForkSpec) -> Option { @@ -74,11 +74,11 @@ impl Test { gas_price, origin: self.unwrap_caller(), block_hashes: Vec::new(), - block_number: self.0.env.number.clone().into(), - block_coinbase: self.0.env.author.clone().into(), - block_timestamp: self.0.env.timestamp.clone().into(), - block_difficulty: self.0.env.difficulty.clone().into(), - block_gas_limit: self.0.env.gas_limit.clone().into(), + block_number: self.0.env.number.into(), + block_coinbase: self.0.env.author.into(), + block_timestamp: self.0.env.timestamp.into(), + block_difficulty: self.0.env.difficulty.into(), + block_gas_limit: self.0.env.gas_limit.into(), chain_id: U256::one(), block_base_fee_per_gas, }) diff --git a/jsontests/src/utils.rs b/jsontests/src/utils.rs index 38b52db..60bbd39 100644 --- a/jsontests/src/utils.rs +++ b/jsontests/src/utils.rs @@ -144,9 +144,9 @@ pub fn assert_valid_hash(h: &H256, b: &BTreeMap) { .collect::>(); let root = ethereum::util::sec_trie_root(tree); - let expect = h.clone().into(); + let expect = h; - if root != expect { + if root != *expect { panic!( "Hash not equal; calculated: {:?}, expect: {:?}\nState: {:#x?}", root, expect, b @@ -157,7 +157,7 @@ pub fn assert_valid_hash(h: &H256, b: &BTreeMap) { pub fn flush() { use std::io::{self, Write}; - io::stdout().flush().ok().expect("Could not flush stdout"); + io::stdout().flush().expect("Could not flush stdout"); } pub mod transaction { diff --git a/jsontests/tests/state.rs b/jsontests/tests/state.rs index e38a1cb..ebefc3b 100644 --- a/jsontests/tests/state.rs +++ b/jsontests/tests/state.rs @@ -13,7 +13,7 @@ pub fn run(dir: &str) { for entry in fs::read_dir(dest).unwrap() { let entry = entry.unwrap(); if let Some(s) = entry.file_name().to_str() { - if s.starts_with(".") { + if s.starts_with('.') { continue; } } @@ -23,8 +23,8 @@ pub fn run(dir: &str) { let file = File::open(path).expect("Open file failed"); let reader = BufReader::new(file); - let coll = serde_json::from_reader::<_, HashMap>(reader) - .expect("Parse test cases failed"); + let coll: HashMap = + serde_json::from_reader(reader).expect("Parse test cases failed"); for (name, test) in coll { statetests::test(&name, test);