diff --git a/ampd/src/block_height_monitor.rs b/ampd/src/block_height_monitor.rs index afdec3292..5ed7e38f4 100644 --- a/ampd/src/block_height_monitor.rs +++ b/ampd/src/block_height_monitor.rs @@ -114,16 +114,16 @@ mod tests { let monitor = BlockHeightMonitor::connect(mock_client) .await .unwrap() - .poll_interval(poll_interval.clone()); + .poll_interval(poll_interval); let exit_token = token.clone(); let latest_block_height = monitor.latest_block_height(); let handle = tokio::spawn(async move { monitor.run(exit_token).await }); - let mut prev_height = latest_block_height.borrow().clone(); + let mut prev_height = *latest_block_height.borrow(); for _ in 1..10 { time::sleep(poll_interval * 2).await; - let next_height = latest_block_height.borrow().clone(); + let next_height = *latest_block_height.borrow(); assert!(next_height > prev_height); prev_height = next_height; } diff --git a/ampd/src/broadcaster/tx.rs b/ampd/src/broadcaster/tx.rs index b4773adfb..831e70cad 100644 --- a/ampd/src/broadcaster/tx.rs +++ b/ampd/src/broadcaster/tx.rs @@ -144,7 +144,7 @@ mod tests { let hash = hasher.finalize(); let priv_key = ecdsa::SigningKey::from_bytes(&priv_key_bytes).unwrap(); - let (signature, _) = priv_key.sign_prehash_recoverable(&hash.to_vec()).unwrap(); + let (signature, _) = priv_key.sign_prehash_recoverable(&hash).unwrap(); Result::<_, Error>::Ok(signature.to_vec()) }) diff --git a/ampd/src/evm/finalizer.rs b/ampd/src/evm/finalizer.rs index 7166a0ebd..80aaef18a 100644 --- a/ampd/src/evm/finalizer.rs +++ b/ampd/src/evm/finalizer.rs @@ -180,7 +180,7 @@ mod tests { let mut rpc_client = MockEthereumClient::new(); let mut block = Block::::default(); let block_number: U64 = 10.into(); - block.number = Some(block_number.clone()); + block.number = Some(block_number); rpc_client .expect_finalized_block() diff --git a/ampd/src/handlers/config.rs b/ampd/src/handlers/config.rs index 5986a016b..22a8a09bf 100644 --- a/ampd/src/handlers/config.rs +++ b/ampd/src/handlers/config.rs @@ -169,7 +169,7 @@ mod tests { rpc_url = 'http://127.0.0.1/' "; - let chain_config: Chain = toml::from_str(&chain_config_toml).unwrap(); + let chain_config: Chain = toml::from_str(chain_config_toml).unwrap(); assert_eq!(chain_config.finalization, Finalization::RPCFinalizedBlock); } } diff --git a/contracts/aggregate-verifier/tests/mock.rs b/contracts/aggregate-verifier/tests/mock.rs index 8db670a52..3aea3f03f 100644 --- a/contracts/aggregate-verifier/tests/mock.rs +++ b/contracts/aggregate-verifier/tests/mock.rs @@ -68,15 +68,13 @@ pub fn make_mock_voting_verifier(app: &mut App) -> Addr { ); let code_id = app.store_code(Box::new(code)); - let contract_address = app - .instantiate_contract( - code_id, - Addr::unchecked("voting_verifier"), - &MockVotingVerifierInstantiateMsg {}, - &[], - "Contract", - None, - ) - .unwrap(); - contract_address + app.instantiate_contract( + code_id, + Addr::unchecked("voting_verifier"), + &MockVotingVerifierInstantiateMsg {}, + &[], + "Contract", + None, + ) + .unwrap() } diff --git a/contracts/aggregate-verifier/tests/test.rs b/contracts/aggregate-verifier/tests/test.rs index 557f98dea..a8b22c067 100644 --- a/contracts/aggregate-verifier/tests/test.rs +++ b/contracts/aggregate-verifier/tests/test.rs @@ -3,7 +3,7 @@ use axelar_wasm_std::VerificationStatus; use connection_router_api::{CrossChainId, Message, ID_SEPARATOR}; use cosmwasm_std::from_json; use cosmwasm_std::Addr; -use cw_multi_test::{App, Executor}; +use cw_multi_test::App; use integration_tests::contract::Contract; use crate::mock::{make_mock_voting_verifier, mark_messages_as_verified}; @@ -46,7 +46,7 @@ fn verify_messages_empty() { &ExecuteMsg::VerifyMessages { messages: vec![] }, ) .unwrap(); - let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(&res.data.unwrap()).unwrap(); + let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap(); assert_eq!(ret, vec![]); } @@ -102,7 +102,7 @@ fn verify_messages_verified() { }, ) .unwrap(); - let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(&res.data.unwrap()).unwrap(); + let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap(); assert_eq!( ret, messages @@ -135,17 +135,13 @@ fn verify_messages_mixed_status() { }, ) .unwrap(); - let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(&res.data.unwrap()).unwrap(); + let ret: Vec<(CrossChainId, VerificationStatus)> = from_json(res.data.unwrap()).unwrap(); assert_eq!( ret, messages .iter() .map(|msg| { - if verified - .iter() - .find(|verified_msg| *verified_msg == msg) - .is_some() - { + if verified.iter().any(|verified_msg| verified_msg == msg) { (msg.cc_id.clone(), VerificationStatus::SucceededOnChain) } else { (msg.cc_id.clone(), VerificationStatus::None) diff --git a/contracts/multisig/src/contract.rs b/contracts/multisig/src/contract.rs index 81ebbc534..009697cd5 100644 --- a/contracts/multisig/src/contract.rs +++ b/contracts/multisig/src/contract.rs @@ -349,11 +349,11 @@ mod tests { let res = query_worker_set(&worker_set_1.id(), deps.as_ref()); assert!(res.is_ok()); - assert_eq!(worker_set_1, from_json(&res.unwrap()).unwrap()); + assert_eq!(worker_set_1, from_json(res.unwrap()).unwrap()); let res = query_worker_set(&worker_set_2.id(), deps.as_ref()); assert!(res.is_ok()); - assert_eq!(worker_set_2, from_json(&res.unwrap()).unwrap()); + assert_eq!(worker_set_2, from_json(res.unwrap()).unwrap()); for (key_type, _) in [ (KeyType::Ecdsa, worker_set_1_id), @@ -406,7 +406,7 @@ mod tests { assert_eq!(res.data, Some(to_json_binary(&session.id).unwrap())); assert_eq!(res.events.len(), 1); - let event = res.events.get(0).unwrap(); + let event = res.events.first().unwrap(); assert_eq!(event.ty, "signing_started".to_string()); assert_eq!( get_event_attribute(event, "session_id").unwrap(), @@ -460,7 +460,7 @@ mod tests { do_start_signing_session(deps.as_mut(), PROVER, worker_set_id, chain_name.clone()) .unwrap(); - let signer = signers.get(0).unwrap().to_owned(); + let signer = signers.first().unwrap().to_owned(); let expected_rewards_msg = WasmMsg::Execute { contract_addr: REWARDS_CONTRACT.to_string(), @@ -474,7 +474,7 @@ mod tests { } .into(); - let res = do_sign(deps.as_mut(), mock_env(), Uint64::from(session_id), &signer); + let res = do_sign(deps.as_mut(), mock_env(), session_id, &signer); assert!(res.is_ok()); @@ -498,7 +498,7 @@ mod tests { assert!(res.messages.iter().any(|m| m.msg == expected_rewards_msg)); - let event = res.events.get(0).unwrap(); + let event = res.events.first().unwrap(); assert_eq!(event.ty, "signature_submitted".to_string()); assert_eq!( get_event_attribute(event, "session_id").unwrap(), @@ -526,7 +526,7 @@ mod tests { do_start_signing_session(deps.as_mut(), PROVER, subkey, "mock-chain".parse().unwrap()) .unwrap(); - let signer = signers.get(0).unwrap().to_owned(); + let signer = signers.first().unwrap().to_owned(); do_sign(deps.as_mut(), mock_env(), session_id, &signer).unwrap(); // second signature @@ -580,7 +580,7 @@ mod tests { { do_start_signing_session(deps.as_mut(), PROVER, subkey, chain_name.clone()).unwrap(); - let signer = signers.get(0).unwrap().to_owned(); + let signer = signers.first().unwrap().to_owned(); do_sign(deps.as_mut(), mock_env(), session_id, &signer).unwrap(); // second signature @@ -610,10 +610,7 @@ mod tests { assert_eq!(signatures.len(), 3); assert!(res.messages.iter().any(|m| m.msg == expected_rewards_msg)); - assert!(!res - .events - .iter() - .any(|e| e.ty == "signing_completed".to_string())); // event is not re-emitted + assert!(!res.events.iter().any(|e| e.ty == *"signing_completed")); // event is not re-emitted } } @@ -628,7 +625,7 @@ mod tests { do_start_signing_session(deps.as_mut(), PROVER, subkey, "mock-chain".parse().unwrap()) .unwrap(); - let signer = signers.get(0).unwrap().to_owned(); + let signer = signers.first().unwrap().to_owned(); do_sign(deps.as_mut(), mock_env(), session_id, &signer).unwrap(); // second signature @@ -664,7 +661,7 @@ mod tests { .unwrap(); let invalid_session_id = Uint64::zero(); - let signer = ecdsa_test_data::signers().get(0).unwrap().to_owned(); + let signer = ecdsa_test_data::signers().first().unwrap().to_owned(); let res = do_sign(deps.as_mut(), mock_env(), invalid_session_id, &signer); assert_eq!( @@ -691,7 +688,7 @@ mod tests { deps.as_mut(), mock_env(), session_id, - signers.get(0).unwrap(), + signers.first().unwrap(), ) .unwrap(); @@ -731,7 +728,7 @@ mod tests { .find(|signer| signer.0.address == worker_set_signer.address) .unwrap(); - assert_eq!(signer.0.weight, Uint256::from(worker_set_signer.weight)); + assert_eq!(signer.0.weight, worker_set_signer.weight); assert_eq!( signer.0.pub_key, worker_set.signers.get(address).unwrap().pub_key diff --git a/contracts/multisig/src/key.rs b/contracts/multisig/src/key.rs index 5392cb285..9088439dd 100644 --- a/contracts/multisig/src/key.rs +++ b/contracts/multisig/src/key.rs @@ -395,7 +395,7 @@ mod ecdsa_tests { .unwrap(); let message = MsgToSign::try_from(ecdsa_test_data::message()).unwrap(); let public_key = PublicKey::try_from((KeyType::Ecdsa, ecdsa_test_data::pub_key())).unwrap(); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert!(result.is_ok(), "{:?}", result) } @@ -409,7 +409,7 @@ mod ecdsa_tests { let signature: Signature = (KeyType::Ecdsa, invalid_signature).try_into().unwrap(); let message = MsgToSign::try_from(ecdsa_test_data::message()).unwrap(); let public_key = PublicKey::try_from((KeyType::Ecdsa, ecdsa_test_data::pub_key())).unwrap(); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert_eq!( result.unwrap_err(), ContractError::SignatureVerificationFailed { @@ -428,7 +428,7 @@ mod ecdsa_tests { let signature: Signature = (KeyType::Ecdsa, invalid_signature).try_into().unwrap(); let message = MsgToSign::try_from(ecdsa_test_data::message()).unwrap(); let public_key = PublicKey::try_from((KeyType::Ecdsa, ecdsa_test_data::pub_key())).unwrap(); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert_eq!( result.unwrap_err(), ContractError::SignatureVerificationFailed { @@ -449,7 +449,7 @@ mod ecdsa_tests { .unwrap(); let message = MsgToSign::try_from(ecdsa_test_data::message()).unwrap(); let public_key = PublicKey::try_from((KeyType::Ecdsa, invalid_pub_key)).unwrap(); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert_eq!( result.unwrap_err(), ContractError::SignatureVerificationFailed { @@ -535,7 +535,7 @@ mod ed25519_tests { let message = MsgToSign::try_from(ed25519_test_data::message()).unwrap(); let public_key = PublicKey::try_from((KeyType::Ed25519, ed25519_test_data::pub_key())).unwrap(); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert!(result.is_ok(), "{:?}", result) } @@ -550,7 +550,7 @@ mod ed25519_tests { let message = MsgToSign::try_from(ed25519_test_data::message()).unwrap(); let public_key = PublicKey::try_from((KeyType::Ed25519, ed25519_test_data::pub_key())).unwrap(); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert_eq!( result.unwrap_err(), ContractError::SignatureVerificationFailed { @@ -569,7 +569,7 @@ mod ed25519_tests { Signature::try_from((KeyType::Ed25519, ed25519_test_data::signature())).unwrap(); let message = MsgToSign::try_from(ed25519_test_data::message()).unwrap(); let public_key = PublicKey::Ed25519(invalid_pub_key); - let result = signature.verify(&message, &public_key); + let result = signature.verify(message, &public_key); assert_eq!( result.unwrap_err(), ContractError::SignatureVerificationFailed { diff --git a/contracts/multisig/src/test/common.rs b/contracts/multisig/src/test/common.rs index 818e8649c..d1c82e23d 100644 --- a/contracts/multisig/src/test/common.rs +++ b/contracts/multisig/src/test/common.rs @@ -128,7 +128,7 @@ pub mod ed25519_test_data { } } -pub fn build_worker_set(key_type: KeyType, signers: &Vec) -> WorkerSet { +pub fn build_worker_set(key_type: KeyType, signers: &[TestSigner]) -> WorkerSet { let mut total_weight = Uint256::zero(); let participants = signers .iter() diff --git a/contracts/voting-verifier/src/contract.rs b/contracts/voting-verifier/src/contract.rs index 9416976da..8a50f5601 100644 --- a/contracts/voting-verifier/src/contract.rs +++ b/contracts/voting-verifier/src/contract.rs @@ -230,7 +230,7 @@ mod test { }; let res = execute(deps.as_mut(), mock_env(), mock_info(SENDER, &[]), msg).unwrap(); - let reply: VerifyMessagesResponse = from_json(&res.data.unwrap()).unwrap(); + let reply: VerifyMessagesResponse = from_json(res.data.unwrap()).unwrap(); assert_eq!(reply.verification_statuses.len(), 2); assert_eq!( reply.verification_statuses, @@ -411,7 +411,7 @@ mod test { assert!(res.is_ok()); let res: Vec<(CrossChainId, VerificationStatus)> = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetMessagesStatus { @@ -449,7 +449,7 @@ mod test { assert!(res.is_ok()); let res: Vec<(CrossChainId, VerificationStatus)> = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetMessagesStatus { @@ -484,7 +484,7 @@ mod test { let res = execute(deps.as_mut(), mock_env(), mock_info(SENDER, &[]), msg).unwrap(); - let reply: VerifyMessagesResponse = from_json(&res.data.unwrap()).unwrap(); + let reply: VerifyMessagesResponse = from_json(res.data.unwrap()).unwrap(); assert_eq!(reply.verification_statuses.len(), messages.len()); assert_eq!( @@ -496,7 +496,7 @@ mod test { ); let statuses: Vec<(CrossChainId, VerificationStatus)> = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetMessagesStatus { @@ -550,7 +550,7 @@ mod test { .unwrap(); let statuses: Vec<(CrossChainId, VerificationStatus)> = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetMessagesStatus { @@ -591,7 +591,7 @@ mod test { assert!(res.is_ok()); let res: VerificationStatus = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetWorkerSetStatus { @@ -641,7 +641,7 @@ mod test { assert!(res.is_ok()); let res: VerificationStatus = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetWorkerSetStatus { @@ -694,7 +694,7 @@ mod test { assert!(res.is_ok()); let res: VerificationStatus = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetWorkerSetStatus { @@ -749,7 +749,7 @@ mod test { assert!(res.is_ok()); let res: VerificationStatus = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetWorkerSetStatus { @@ -796,7 +796,7 @@ mod test { assert!(res.is_ok()); let res: VerificationStatus = from_json( - &query( + query( deps.as_ref(), mock_env(), QueryMsg::GetWorkerSetStatus {