diff --git a/ethers-contract/ethers-contract-abigen/src/contract/structs.rs b/ethers-contract/ethers-contract-abigen/src/contract/structs.rs index c1a51dede..947604b96 100644 --- a/ethers-contract/ethers-contract-abigen/src/contract/structs.rs +++ b/ethers-contract/ethers-contract-abigen/src/contract/structs.rs @@ -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]} } } diff --git a/ethers-contract/ethers-contract-abigen/src/multi.rs b/ethers-contract/ethers-contract-abigen/src/multi.rs index 6266abcc2..37c8ab763 100644 --- a/ethers-contract/ethers-contract-abigen/src/multi.rs +++ b/ethers-contract/ethers-contract-abigen/src/multi.rs @@ -782,7 +782,7 @@ mod tests { let result = panic::catch_unwind(|| test(&context)); - assert!(result.is_ok()) + result.unwrap() } #[test] diff --git a/ethers-contract/ethers-contract-abigen/src/rawabi.rs b/ethers-contract/ethers-contract-abigen/src/rawabi.rs index 086bec4c3..c25618f79 100644 --- a/ethers-contract/ethers-contract-abigen/src/rawabi.rs +++ b/ethers-contract/ethers-contract-abigen/src/rawabi.rs @@ -207,7 +207,7 @@ mod tests { use ethers_core::abi::Abi; fn assert_has_bytecode(s: &str) { - match serde_json::from_str::(&s).unwrap() { + match serde_json::from_str::(s).unwrap() { JsonAbi::Object(abi) => { assert!(abi.bytecode.is_some()); } diff --git a/ethers-contract/ethers-contract-abigen/src/util.rs b/ethers-contract/ethers-contract-abigen/src/util.rs index 33936e098..ec4651046 100644 --- a/ethers-contract/ethers-contract-abigen/src/util.rs +++ b/ethers-contract/ethers-contract-abigen/src/util.rs @@ -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] diff --git a/ethers-contract/ethers-contract-derive/src/utils.rs b/ethers-contract/ethers-contract-derive/src/utils.rs index abef0999b..65319f067 100644 --- a/ethers-contract/ethers-contract-derive/src/utils.rs +++ b/ethers-contract/ethers-contract-derive/src/utils.rs @@ -70,7 +70,7 @@ 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) => { @@ -78,7 +78,7 @@ pub fn param_type_quote(kind: &ParamType) -> proc_macro2::TokenStream { 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)} } diff --git a/ethers-contract/tests/it/common/mod.rs b/ethers-contract/tests/it/common/mod.rs index 3ec3e3185..7ed4be56d 100644 --- a/ethers-contract/tests/it/common/mod.rs +++ b/ethers-contract/tests/it/common/mod.rs @@ -52,6 +52,6 @@ pub fn connect(anvil: &AnvilInstance, idx: usize) -> Arc> { pub async fn deploy(client: Arc, abi: Abi, bytecode: Bytes) -> Contract { 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() } diff --git a/ethers-contract/tests/it/contract.rs b/ethers-contract/tests/it/contract.rs index f40c76b13..6a593c5c8 100644 --- a/ethers-contract/tests/it/contract.rs +++ b/ethers-contract/tests/it/contract.rs @@ -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()); diff --git a/ethers-core/src/abi/struct_def.rs b/ethers-core/src/abi/struct_def.rs index 3a77bb7e1..ff8945a0e 100644 --- a/ethers-core/src/abi/struct_def.rs +++ b/ethers-core/src/abi/struct_def.rs @@ -509,7 +509,7 @@ mod tests { ] .iter() .for_each(|s| { - assert!(parse_mapping(s).is_err()); + parse_mapping(s).unwrap_err(); }); } diff --git a/ethers-core/src/types/i256.rs b/ethers-core/src/types/i256.rs index 48d8a28d3..6b00105bb 100644 --- a/ethers-core/src/types/i256.rs +++ b/ethers-core/src/types/i256.rs @@ -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] diff --git a/ethers-etherscan/src/account.rs b/ethers-etherscan/src/account.rs index a33f44841..8893a2c12 100644 --- a/ethers-etherscan/src/account.rs +++ b/ethers-etherscan/src/account.rs @@ -681,7 +681,7 @@ mod tests { None, ) .await; - assert!(balance.is_ok()); + balance.unwrap(); }) .await } @@ -717,7 +717,7 @@ mod tests { None, ) .await; - assert!(txs.is_ok()); + txs.unwrap(); }) .await } @@ -736,7 +736,7 @@ mod tests { None, ) .await; - assert!(txs.is_ok()); + txs.unwrap(); }) .await } @@ -757,7 +757,7 @@ mod tests { None, ) .await; - assert!(txs.is_ok()); + txs.unwrap(); }) .await } @@ -800,7 +800,7 @@ mod tests { None, ) .await; - assert!(txs.is_ok()); + txs.unwrap(); }) .await } @@ -820,7 +820,7 @@ mod tests { None, ) .await; - assert!(txs.is_ok()); + txs.unwrap(); }) .await } @@ -838,7 +838,7 @@ mod tests { None, ) .await; - assert!(blocks.is_ok()); + blocks.unwrap(); }) .await } @@ -854,6 +854,6 @@ mod tests { let txs = client .get_transactions(&"0x1549ea9b546ba9ffb306d78a1e1f304760cc4abf".parse().unwrap(), None) .await; - assert!(txs.is_ok()); + txs.unwrap(); } } diff --git a/ethers-etherscan/src/gas.rs b/ethers-etherscan/src/gas.rs index 94e93b1e7..988a3285d 100644 --- a/ethers-etherscan/src/gas.rs +++ b/ethers-etherscan/src/gas.rs @@ -84,7 +84,7 @@ mod tests { let result = client.gas_estimate(2000000000u32.into()).await; - assert!(result.is_ok()); + result.unwrap(); }) .await } diff --git a/ethers-etherscan/src/transaction.rs b/ethers-etherscan/src/transaction.rs index 9259b097e..39b1cc3a4 100644 --- a/ethers-etherscan/src/transaction.rs +++ b/ethers-etherscan/src/transaction.rs @@ -69,7 +69,7 @@ mod tests { ) .await; - assert!(status.is_ok()); + status.unwrap(); }) .await } @@ -105,7 +105,7 @@ mod tests { ) .await; - assert!(success.is_ok()); + success.unwrap(); }) .await } diff --git a/ethers-middleware/src/signer.rs b/ethers-middleware/src/signer.rs index 33cd92ff0..e38ed7e1a 100644 --- a/ethers-middleware/src/signer.rs +++ b/ethers-middleware/src/signer.rs @@ -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] diff --git a/ethers-middleware/tests/gas_oracle.rs b/ethers-middleware/tests/gas_oracle.rs index 4e4270e89..10db9ba07 100644 --- a/ethers-middleware/tests/gas_oracle.rs +++ b/ethers-middleware/tests/gas_oracle.rs @@ -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] @@ -71,13 +71,13 @@ 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] @@ -85,5 +85,5 @@ 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(); } diff --git a/ethers-providers/src/transports/ws.rs b/ethers-providers/src/transports/ws.rs index eebbccda8..098a2d876 100644 --- a/ethers-providers/src/transports/ws.rs +++ b/ethers-providers/src/transports/ws.rs @@ -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(); } } diff --git a/ethers-signers/src/wallet/mod.rs b/ethers-signers/src/wallet/mod.rs index d60231a52..dc2a811f0 100644 --- a/ethers-signers/src/wallet/mod.rs +++ b/ethers-signers/src/wallet/mod.rs @@ -68,7 +68,6 @@ pub struct Wallet> { } impl> Wallet { - /// 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 } diff --git a/ethers-signers/src/wallet/private_key.rs b/ethers-signers/src/wallet/private_key.rs index 8003fa31f..10f0e9b71 100644 --- a/ethers-signers/src/wallet/private_key.rs +++ b/ethers-signers/src/wallet/private_key.rs @@ -166,7 +166,7 @@ mod tests { let key2 = Wallet::::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] @@ -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] @@ -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] @@ -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] diff --git a/ethers-solc/src/cache.rs b/ethers-solc/src/cache.rs index 4e837bdad..06657c9cb 100644 --- a/ethers-solc/src/cache.rs +++ b/ethers-solc/src/cache.rs @@ -528,7 +528,7 @@ impl CacheEntry { &'a self, version: &'a Version, ) -> impl Iterator + '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 diff --git a/ethers-solc/src/filter.rs b/ethers-solc/src/filter.rs index 0e1d2056c..42cce5ff0 100644 --- a/ethers-solc/src/filter.rs +++ b/ethers-solc/src/filter.rs @@ -221,7 +221,7 @@ impl FilteredSources { /// Returns all dirty files pub fn dirty_files(&self) -> impl Iterator + 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)) } }