9951 clippy errors in the test suite (#10030)

automerge
This commit is contained in:
Kristofer Peterson
2020-05-15 17:35:43 +01:00
committed by GitHub
parent 1da1667920
commit 58ef02f02b
106 changed files with 713 additions and 827 deletions

View File

@@ -97,10 +97,8 @@ mod tests {
let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetBalance, account_balance_response.clone());
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
assert_eq!(
check_account_for_fee(&rpc_client, &pubkey, &fee_calculator, &message0).unwrap(),
()
);
check_account_for_fee(&rpc_client, &pubkey, &fee_calculator, &message0)
.expect("unexpected result");
let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetBalance, account_balance_response.clone());
@@ -128,16 +126,13 @@ mod tests {
mocks.insert(RpcRequest::GetBalance, account_balance_response);
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
assert_eq!(
check_account_for_multiple_fees(
&rpc_client,
&pubkey,
&fee_calculator,
&[&message0, &message0]
)
.unwrap(),
()
);
check_account_for_multiple_fees(
&rpc_client,
&pubkey,
&fee_calculator,
&[&message0, &message0],
)
.expect("unexpected result");
}
#[test]
@@ -194,19 +189,14 @@ mod tests {
#[test]
fn test_check_unique_pubkeys() {
let pubkey0 = Pubkey::new_rand();
let pubkey_clone = pubkey0.clone();
let pubkey_clone = pubkey0;
let pubkey1 = Pubkey::new_rand();
assert_eq!(
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
.unwrap(),
()
);
assert_eq!(
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "foo".to_string()))
.unwrap(),
()
);
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
.expect("unexpected result");
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "foo".to_string()))
.expect("unexpected result");
assert!(check_unique_pubkeys(
(&pubkey0, "foo".to_string()),
(&pubkey_clone, "bar".to_string())

View File

@@ -2703,6 +2703,7 @@ mod tests {
}
#[test]
#[allow(clippy::cognitive_complexity)]
fn test_cli_parse_command() {
let test_commands = app("test", "desc", "version");
@@ -2800,7 +2801,7 @@ mod tests {
);
// Test Confirm Subcommand
let signature = Signature::new(&vec![1; 64]);
let signature = Signature::new(&[1; 64]);
let signature_string = format!("{:?}", signature);
let test_confirm =
test_commands
@@ -3235,6 +3236,7 @@ mod tests {
}
#[test]
#[allow(clippy::cognitive_complexity)]
fn test_cli_process_command() {
// Success cases
let mut config = CliConfig::default();
@@ -3774,7 +3776,7 @@ mod tests {
blockhash_query::Source::NonceAccount(nonce_address),
blockhash
),
nonce_account: Some(nonce_address.into()),
nonce_account: Some(nonce_address),
nonce_authority: 1,
fee_payer: 0,
},

View File

@@ -303,19 +303,19 @@ mod tests {
);
mocks.insert(
RpcRequest::GetFeeCalculatorForBlockhash,
get_fee_calculator_for_blockhash_response.clone(),
get_fee_calculator_for_blockhash_response,
);
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
assert_eq!(
BlockhashQuery::FeeCalculator(Source::Cluster, test_blockhash)
.get_blockhash_and_fee_calculator(&rpc_client)
.unwrap(),
(test_blockhash, rpc_fee_calc.clone()),
(test_blockhash, rpc_fee_calc),
);
let mut mocks = HashMap::new();
mocks.insert(
RpcRequest::GetRecentBlockhash,
get_recent_blockhash_response.clone(),
get_recent_blockhash_response,
);
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
assert_eq!(
@@ -347,7 +347,7 @@ mod tests {
let rpc_nonce_account = RpcAccount::encode(nonce_account);
let get_account_response = json!(Response {
context: RpcResponseContext { slot: 1 },
value: json!(Some(rpc_nonce_account.clone())),
value: json!(Some(rpc_nonce_account)),
});
let mut mocks = HashMap::new();
@@ -366,7 +366,7 @@ mod tests {
BlockhashQuery::FeeCalculator(Source::NonceAccount(nonce_pubkey), nonce_blockhash)
.get_blockhash_and_fee_calculator(&rpc_client)
.unwrap(),
(nonce_blockhash, nonce_fee_calc.clone()),
(nonce_blockhash, nonce_fee_calc),
);
let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetAccountInfo, get_account_response.clone());
@@ -377,7 +377,7 @@ mod tests {
.is_err()
);
let mut mocks = HashMap::new();
mocks.insert(RpcRequest::GetAccountInfo, get_account_response.clone());
mocks.insert(RpcRequest::GetAccountInfo, get_account_response);
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
assert_eq!(
BlockhashQuery::None(nonce_blockhash)

View File

@@ -1482,6 +1482,7 @@ mod tests {
}
#[test]
#[allow(clippy::cognitive_complexity)]
fn test_parse_command() {
let test_commands = app("test", "desc", "version");
let default_keypair = Keypair::new();
@@ -2861,7 +2862,7 @@ mod tests {
blockhash_query::Source::NonceAccount(nonce_account),
nonce_hash
),
nonce_account: Some(nonce_account.into()),
nonce_account: Some(nonce_account),
nonce_authority: 1,
split_stake_account: 2,
seed: None,

View File

@@ -508,9 +508,7 @@ mod tests {
let mut info = Map::new();
info.insert("name".to_string(), Value::String("Alice".to_string()));
let info_string = serde_json::to_string(&Value::Object(info.clone())).unwrap();
let validator_info = ValidatorInfo {
info: info_string.clone(),
};
let validator_info = ValidatorInfo { info: info_string };
let data = serialize(&(config, validator_info)).unwrap();
assert_eq!(
@@ -547,9 +545,7 @@ mod tests {
info.insert("details".to_string(), Value::String(max_long_string));
let info_string = serde_json::to_string(&Value::Object(info)).unwrap();
let validator_info = ValidatorInfo {
info: info_string.clone(),
};
let validator_info = ValidatorInfo { info: info_string };
assert_eq!(
serialized_size(&validator_info).unwrap(),