Skip to content

Commit

Permalink
chore: fix base gas limit test and clippy (#8961)
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy authored Sep 26, 2024
1 parent c59d97e commit a0ff7bd
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 6 deletions.
2 changes: 2 additions & 0 deletions crates/anvil/src/eth/backend/mem/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ pub struct MinedTransactionReceipt {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;
use crate::eth::backend::db::Db;
use alloy_primitives::{hex, Address};
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/tests/it/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,8 @@ async fn test_base_fork_gas_limit() {
.unwrap()
.unwrap();

assert_eq!(api.gas_limit(), uint!(120_000_000_U256));
assert_eq!(block.header.gas_limit, 120_000_000_u128);
assert!(api.gas_limit() >= uint!(132_000_000_U256));
assert!(block.header.gas_limit >= 132_000_000_u128);
}

// <https://github.com/foundry-rs/foundry/issues/7023>
Expand Down
2 changes: 2 additions & 0 deletions crates/anvil/tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::needless_return)]

mod abi;
mod anvil;
mod anvil_api;
Expand Down
1 change: 1 addition & 0 deletions crates/cast/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn main() -> Result<()> {
main_args(args)
}

#[allow(clippy::needless_return)]
#[tokio::main]
async fn main_args(args: CastArgs) -> Result<()> {
match args.cmd {
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/src/rlp_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Decodable for Item {

impl Item {
pub(crate) fn value_to_item(value: &Value) -> eyre::Result<Self> {
return match value {
match value {
Value::Null => Ok(Self::Data(vec![])),
Value::Bool(_) => {
eyre::bail!("RLP input can not contain booleans")
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/test/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ pub(crate) fn handle_expect_emit(
let Some(expected) = &event_to_fill_or_check.log else {
// Unless the caller is trying to match an anonymous event, the first topic must be
// filled.
if event_to_fill_or_check.anonymous || log.topics().first().is_some() {
if event_to_fill_or_check.anonymous || !log.topics().is_empty() {
event_to_fill_or_check.log = Some(log.data.clone());
// If we only filled the expected log then we put it back at the same position.
state.expected_emits.insert(index_to_fill_or_check, event_to_fill_or_check);
Expand Down
1 change: 1 addition & 0 deletions crates/chisel/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn main() -> eyre::Result<()> {
main_args(args)
}

#[allow(clippy::needless_return)]
#[tokio::main]
async fn main_args(args: Chisel) -> eyre::Result<()> {
// Keeps track of whether or not an interrupt was the last input
Expand Down
2 changes: 2 additions & 0 deletions crates/common/src/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ pub fn parse_signatures(tokens: Vec<String>) -> ParsedSignatures {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;

#[tokio::test(flavor = "multi_thread")]
Expand Down
2 changes: 2 additions & 0 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,8 @@ fn apply_state_changeset(

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use crate::{backend::Backend, fork::CreateFork, opts::EvmOpts};
use alloy_primitives::{Address, U256};
use alloy_provider::Provider;
Expand Down
2 changes: 2 additions & 0 deletions crates/evm/core/src/fork/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ impl DatabaseRef for ForkDbSnapshot {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;
use crate::backend::BlockchainDbMeta;
use foundry_common::provider::get_http_provider;
Expand Down
2 changes: 2 additions & 0 deletions crates/evm/traces/src/identifier/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ impl Drop for SignaturesIdentifier {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;

#[tokio::test(flavor = "multi_thread")]
Expand Down
2 changes: 2 additions & 0 deletions crates/forge/bin/cmd/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ impl EtherscanClient for Client {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;
use alloy_primitives::hex;
use foundry_compilers::Artifact;
Expand Down
1 change: 1 addition & 0 deletions crates/forge/bin/cmd/doc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl Server {
}
}

#[allow(clippy::needless_return)]
#[tokio::main]
async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) -> io::Result<()> {
let file_404 = build_dir.join(file_404);
Expand Down
2 changes: 2 additions & 0 deletions crates/forge/tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::needless_return)]

pub mod config;
pub mod test_helpers;

Expand Down
3 changes: 1 addition & 2 deletions crates/script/src/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ impl ScriptSequence {

/// Converts the `sig` argument into the corresponding file path.
///
/// This accepts either the signature of the function or the raw calldata
/// This accepts either the signature of the function or the raw calldata.
pub fn sig_to_file_name(sig: &str) -> String {
if let Some((name, _)) = sig.split_once('(') {
// strip until call argument parenthesis
Expand Down
2 changes: 2 additions & 0 deletions crates/test-utils/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ fn next_url(is_ws: bool, chain: NamedChain) -> String {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;
use alloy_primitives::address;
use foundry_config::Chain;
Expand Down
2 changes: 2 additions & 0 deletions crates/verify/src/etherscan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ async fn ensure_solc_build_metadata(version: Version) -> Result<Version> {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use super::*;
use clap::Parser;
use foundry_common::fs;
Expand Down
2 changes: 2 additions & 0 deletions crates/wallets/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ impl From<RawWalletOpts> for WalletOpts {

#[cfg(test)]
mod tests {
#![allow(clippy::needless_return)]

use alloy_signer::Signer;
use std::{path::Path, str::FromStr};

Expand Down

0 comments on commit a0ff7bd

Please sign in to comment.