Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
vimpunk committed Mar 20, 2023
1 parent 41b2e25 commit 169af74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions jsontests/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MemoryVicinity> {
Expand Down Expand Up @@ -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,
})
Expand Down
6 changes: 3 additions & 3 deletions jsontests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ pub fn assert_valid_hash(h: &H256, b: &BTreeMap<H160, MemoryAccount>) {
.collect::<Vec<_>>();

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
Expand All @@ -157,7 +157,7 @@ pub fn assert_valid_hash(h: &H256, b: &BTreeMap<H160, MemoryAccount>) {
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 {
Expand Down
6 changes: 3 additions & 3 deletions jsontests/tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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<String, statetests::Test>>(reader)
.expect("Parse test cases failed");
let coll: HashMap<String, statetests::Test> =
serde_json::from_reader(reader).expect("Parse test cases failed");

for (name, test) in coll {
statetests::test(&name, test);
Expand Down

0 comments on commit 169af74

Please sign in to comment.