Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT committed Mar 22, 2024
1 parent fc50023 commit 14316cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ fn test_block_9() {
let key = Felt::from_hex(key_hex).unwrap();
let value = Felt::from_hex(value_hex).unwrap();
bonsai_storage
.insert(&identifier, keyer(key).as_bitslice(), &value.into())
.insert(identifier, keyer(key).as_bitslice(), &value)
.expect("Failed to insert storage update into trie");
}

Expand All @@ -1007,12 +1007,12 @@ fn test_block_9() {
.commit(id)
.expect("Failed to commit to bonsai storage");
let root_hash = bonsai_storage
.root_hash(&identifier)
.root_hash(identifier)
.expect("Failed to get root hash");

println!("Expected: 0x010AA5D1D36847AE64BA074B3A878BFD1A9AEAA952F6777C727EEA6AE6B2C99F\nFound: {root_hash:#x}");
assert_eq!(
Felt::from(root_hash),
root_hash,
Felt::from_hex("0x010AA5D1D36847AE64BA074B3A878BFD1A9AEAA952F6777C727EEA6AE6B2C99F")
.unwrap()
);
Expand All @@ -1021,10 +1021,10 @@ fn test_block_9() {
let block_9 = [("0x5", "0x0")];

for (key_hex, value_hex) in block_9.iter() {
let key = Felt::from_hex(key_hex).unwrap().into();
let key = Felt::from_hex(key_hex).unwrap();
let value = Felt::from_hex(value_hex).unwrap();
bonsai_storage
.insert(&identifier, keyer(key).as_bitslice(), &value.into())
.insert(identifier, keyer(key).as_bitslice(), &value)
.expect("Failed to insert storage update into trie");
}

Expand All @@ -1033,12 +1033,12 @@ fn test_block_9() {
.commit(id)
.expect("Failed to commit to bonsai storage");
let root_hash = bonsai_storage
.root_hash(&identifier)
.root_hash(identifier)
.expect("Failed to get root hash");

println!("Expected: 0x00072F7E2EC1A2F05342503B49AECD83E14884AE374A8570F2F6F7B868CF94AE\nFound: {root_hash:#x}");
assert_eq!(
Felt::from(root_hash),
root_hash,
Felt::from_hex("0x00072F7E2EC1A2F05342503B49AECD83E14884AE374A8570F2F6F7B868CF94AE")
.unwrap()
);
Expand Down
6 changes: 3 additions & 3 deletions src/trie/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl<H: StarkHash + Send + Sync, DB: BonsaiDatabase, CommitID: Id> MerkleTrees<H
}

pub(crate) fn commit(&mut self) -> Result<(), BonsaiStorageError<DB::DatabaseError>> {
#[allow(clippy::type_complexity)]
let db_changes: Vec<
Result<
HashMap<TrieKey, InsertOrRemove<Vec<u8>>>,
Expand Down Expand Up @@ -313,6 +314,7 @@ impl<H: StarkHash + Send + Sync> MerkleTree<H> {
}

/// Calculate all the new hashes and the root hash.
#[allow(clippy::type_complexity)]
pub(crate) fn get_updates<DB: BonsaiDatabase>(
&mut self,
) -> Result<HashMap<TrieKey, InsertOrRemove<Vec<u8>>>, BonsaiStorageError<DB::DatabaseError>>
Expand Down Expand Up @@ -564,12 +566,10 @@ impl<H: StarkHash + Send + Sync> MerkleTree<H> {
Direction::Left => binary.left = NodeHandle::Hash(value),
Direction::Right => binary.right = NodeHandle::Hash(value),
};

return;
}
}
_ => {}
};
}
});
for (id, node) in nodes_to_add {
self.storage_nodes.0.insert(id, node);
Expand Down

0 comments on commit 14316cd

Please sign in to comment.