Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
chore(clippy): make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Aug 1, 2022
1 parent e370786 commit 52b5628
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,11 @@ fn expand_struct_type(struct_ty: &StructFieldType) -> TokenStream {
quote! {#ty}
}
StructFieldType::Array(ty) => {
let ty = expand_struct_type(&*ty);
let ty = expand_struct_type(ty);
quote! {::std::vec::Vec<#ty>}
}
StructFieldType::FixedArray(ty, size) => {
let ty = expand_struct_type(&*ty);
let ty = expand_struct_type(ty);
quote! { [#ty; #size]}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/ethers-contract-abigen/src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ mod tests {

let result = panic::catch_unwind(|| test(&context));

assert!(result.is_ok())
result.unwrap()
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/ethers-contract-abigen/src/rawabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod tests {
use ethers_core::abi::Abi;

fn assert_has_bytecode(s: &str) {
match serde_json::from_str::<JsonAbi>(&s).unwrap() {
match serde_json::from_str::<JsonAbi>(s).unwrap() {
JsonAbi::Object(abi) => {
assert!(abi.bytecode.is_some());
}
Expand Down
10 changes: 2 additions & 8 deletions ethers-contract/ethers-contract-abigen/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,12 @@ mod tests {

#[test]
fn parse_address_missing_prefix() {
assert!(
parse_address("0000000000000000000000000000000000000000").is_err(),
"parsing address not starting with 0x should fail"
);
let _ = parse_address("0000000000000000000000000000000000000000").unwrap_err();
}

#[test]
fn parse_address_address_too_short() {
assert!(
parse_address("0x00000000000000").is_err(),
"parsing address not starting with 0x should fail"
);
let _ = parse_address("0x00000000000000").unwrap_err();
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions ethers-contract/ethers-contract-derive/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ pub fn param_type_quote(kind: &ParamType) -> proc_macro2::TokenStream {
quote! {#core_crate::abi::ParamType::String}
}
ParamType::Array(ty) => {
let ty = param_type_quote(&*ty);
let ty = param_type_quote(ty);
quote! {#core_crate::abi::ParamType::Array(Box::new(#ty))}
}
ParamType::FixedBytes(size) => {
let size = Literal::usize_suffixed(*size);
quote! {#core_crate::abi::ParamType::FixedBytes(#size)}
}
ParamType::FixedArray(ty, size) => {
let ty = param_type_quote(&*ty);
let ty = param_type_quote(ty);
let size = Literal::usize_suffixed(*size);
quote! {#core_crate::abi::ParamType::FixedArray(Box::new(#ty),#size)}
}
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/tests/it/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ pub fn connect(anvil: &AnvilInstance, idx: usize) -> Arc<Provider<Http>> {
pub async fn deploy<M: Middleware>(client: Arc<M>, abi: Abi, bytecode: Bytes) -> Contract<M> {
let factory = ContractFactory::new(abi, bytecode, client);
let deployer = factory.deploy("initial value".to_string()).unwrap();
assert!(deployer.call().await.is_ok());
deployer.call().await.unwrap();
deployer.legacy().send().await.unwrap()
}
2 changes: 1 addition & 1 deletion ethers-contract/tests/it/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod eth_tests {
let deployer = factory.deploy("initial value".to_string()).unwrap().legacy();
// dry runs the deployment of the contract. takes the deployer by reference, no need to
// clone.
assert!(deployer.call().await.is_ok());
deployer.call().await.unwrap();
let (contract, receipt) = deployer.clone().send_with_receipt().await.unwrap();
assert_eq!(receipt.contract_address.unwrap(), contract.address());

Expand Down
2 changes: 1 addition & 1 deletion ethers-core/src/abi/struct_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ mod tests {
]
.iter()
.for_each(|s| {
assert!(parse_mapping(s).is_err());
parse_mapping(s).unwrap_err();
});
}

Expand Down
6 changes: 3 additions & 3 deletions ethers-core/src/types/i256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,9 +1382,9 @@ mod tests {

assert_eq!(I256::try_from(large_unsigned).unwrap(), large_positive);
assert_eq!(U256::try_from(large_positive).unwrap(), large_unsigned);
assert!(I256::try_from(U256::MAX).is_err());
assert!(U256::try_from(small_negative).is_err());
assert!(U256::try_from(large_negative).is_err());
I256::try_from(U256::MAX).unwrap_err();
U256::try_from(small_negative).unwrap_err();
U256::try_from(large_negative).unwrap_err();
}

#[test]
Expand Down
16 changes: 8 additions & 8 deletions ethers-etherscan/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ mod tests {
None,
)
.await;
assert!(balance.is_ok());
balance.unwrap();
})
.await
}
Expand Down Expand Up @@ -717,7 +717,7 @@ mod tests {
None,
)
.await;
assert!(txs.is_ok());
txs.unwrap();
})
.await
}
Expand All @@ -736,7 +736,7 @@ mod tests {
None,
)
.await;
assert!(txs.is_ok());
txs.unwrap();
})
.await
}
Expand All @@ -757,7 +757,7 @@ mod tests {
None,
)
.await;
assert!(txs.is_ok());
txs.unwrap();
})
.await
}
Expand Down Expand Up @@ -800,7 +800,7 @@ mod tests {
None,
)
.await;
assert!(txs.is_ok());
txs.unwrap();
})
.await
}
Expand All @@ -820,7 +820,7 @@ mod tests {
None,
)
.await;
assert!(txs.is_ok());
txs.unwrap();
})
.await
}
Expand All @@ -838,7 +838,7 @@ mod tests {
None,
)
.await;
assert!(blocks.is_ok());
blocks.unwrap();
})
.await
}
Expand All @@ -854,6 +854,6 @@ mod tests {
let txs = client
.get_transactions(&"0x1549ea9b546ba9ffb306d78a1e1f304760cc4abf".parse().unwrap(), None)
.await;
assert!(txs.is_ok());
txs.unwrap();
}
}
2 changes: 1 addition & 1 deletion ethers-etherscan/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mod tests {

let result = client.gas_estimate(2000000000u32.into()).await;

assert!(result.is_ok());
result.unwrap();
})
.await
}
Expand Down
4 changes: 2 additions & 2 deletions ethers-etherscan/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
)
.await;

assert!(status.is_ok());
status.unwrap();
})
.await
}
Expand Down Expand Up @@ -105,7 +105,7 @@ mod tests {
)
.await;

assert!(success.is_ok());
success.unwrap();
})
.await
}
Expand Down
2 changes: 1 addition & 1 deletion ethers-middleware/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ mod tests {
let tx = client.sign_transaction(tx).await.unwrap();

let expected_rlp = Bytes::from(hex::decode("f86b808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080820a95a08290324bae25ca0490077e0d1f4098730333088f6a500793fa420243f35c6b23a06aca42876cd28fdf614a4641e64222fee586391bb3f4061ed5dfefac006be850").unwrap());
assert_eq!(tx.clone(), expected_rlp);
assert_eq!(tx, expected_rlp);
}

#[tokio::test]
Expand Down
8 changes: 4 additions & 4 deletions ethers-middleware/tests/gas_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async fn eth_gas_station() {
// initialize and fetch gas estimates from EthGasStation
let eth_gas_station_oracle = EthGasStation::default();
let data = eth_gas_station_oracle.fetch().await;
assert!(data.is_ok());
data.unwrap();
}

#[tokio::test]
Expand All @@ -71,19 +71,19 @@ async fn etherscan() {
// since etherscan does not support `fastest` category, we expect an error
let etherscan_oracle = Etherscan::new(etherscan_client.clone()).category(GasCategory::Fastest);
let data = etherscan_oracle.fetch().await;
assert!(data.is_err());
data.unwrap_err();

// but fetching the `standard` gas price should work fine
let etherscan_oracle = Etherscan::new(etherscan_client).category(GasCategory::SafeLow);

let data = etherscan_oracle.fetch().await;
assert!(data.is_ok());
data.unwrap();
}

#[tokio::test]
async fn etherchain() {
// initialize and fetch gas estimates from Etherchain
let etherchain_oracle = Etherchain::default().category(GasCategory::Fast);
let data = etherchain_oracle.fetch().await;
assert!(data.is_ok());
data.unwrap();
}
2 changes: 1 addition & 1 deletion ethers-providers/src/transports/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,6 @@ mod tests {
let malformed_data = String::from("not a valid message");
let (_, stream) = mpsc::unbounded();
let resp = WsServer::new(ws, stream).handle_text(malformed_data).await;
assert!(resp.is_err(), "Deserialization should not fail silently");
resp.unwrap_err();
}
}
1 change: 0 additions & 1 deletion ethers-signers/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pub struct Wallet<D: DigestSigner<Sha256Proxy, RecoverableSignature>> {
}

impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> {

/// Construct a new wallet with an external Signer
pub fn new_with_signer(signer: D, address: Address, chain_id: u64) -> Self {
Wallet { signer, address, chain_id }
Expand Down
8 changes: 4 additions & 4 deletions ethers-signers/src/wallet/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mod tests {
let key2 = Wallet::<SigningKey>::decrypt_keystore(&path.clone(), "randpsswd").unwrap();
let signature2 = key2.sign_message(message).await.unwrap();
assert_eq!(signature, signature2);
assert!(std::fs::remove_file(&path).is_ok());
std::fs::remove_file(&path).unwrap();
}

#[tokio::test]
Expand Down Expand Up @@ -216,7 +216,7 @@ mod tests {

let sig = wallet.sign_transaction(&tx).await.unwrap();
let sighash = tx.sighash();
assert!(sig.verify(sighash, wallet.address).is_ok());
sig.verify(sighash, wallet.address).unwrap();
}

#[tokio::test]
Expand Down Expand Up @@ -249,7 +249,7 @@ mod tests {
let mut tx = tx;
tx.set_chain_id(1);
let sighash = tx.sighash();
assert!(sig.verify(sighash, wallet.address).is_ok());
sig.verify(sighash, wallet.address).unwrap();
}

#[test]
Expand Down Expand Up @@ -290,7 +290,7 @@ mod tests {
let mut tx = tx;
tx.set_chain_id(chain_id);
let sighash = tx.sighash();
assert!(sig.verify(sighash, wallet.address).is_ok());
sig.verify(sighash, wallet.address).unwrap();
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ethers-solc/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ impl CacheEntry {
&'a self,
version: &'a Version,
) -> impl Iterator<Item = &'a PathBuf> + 'a {
self.artifacts_versions().filter_map(move |(ver, file)| (ver == version).then(|| file))
self.artifacts_versions().filter_map(move |(ver, file)| (ver == version).then_some(file))
}

/// Iterator that yields all artifact files
Expand Down
2 changes: 1 addition & 1 deletion ethers-solc/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl FilteredSources {

/// Returns all dirty files
pub fn dirty_files(&self) -> impl Iterator<Item = &PathBuf> + fmt::Debug + '_ {
self.0.iter().filter_map(|(k, s)| s.is_dirty().then(|| k))
self.0.iter().filter_map(|(k, s)| s.is_dirty().then_some(k))
}
}

Expand Down

0 comments on commit 52b5628

Please sign in to comment.