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(),

View File

@ -354,7 +354,7 @@ fn test_offline_stake_delegation_and_deactivation() {
config_validator.command = CliCommand::CreateStakeAccount {
stake_account: 1,
seed: None,
staker: Some(config_offline.signers[0].pubkey().into()),
staker: Some(config_offline.signers[0].pubkey()),
withdrawer: None,
lockup: Lockup::default(),
amount: SpendAmount::Some(50_000),
@ -1033,7 +1033,7 @@ fn test_stake_split() {
check_balance(0, &rpc_client, &split_account.pubkey());
config_offline.signers.push(&split_account);
config_offline.command = CliCommand::SplitStake {
stake_account_pubkey: stake_account_pubkey,
stake_account_pubkey,
stake_authority: 0,
sign_only: true,
blockhash_query: BlockhashQuery::None(nonce_hash),
@ -1051,7 +1051,7 @@ fn test_stake_split() {
let offline_presigner = sign_only.presigner_of(&offline_pubkey).unwrap();
config.signers = vec![&offline_presigner, &split_account];
config.command = CliCommand::SplitStake {
stake_account_pubkey: stake_account_pubkey,
stake_account_pubkey,
stake_authority: 0,
sign_only: false,
blockhash_query: BlockhashQuery::FeeCalculator(
@ -1165,7 +1165,7 @@ fn test_stake_set_lockup() {
// Online set lockup
let lockup = LockupArgs {
unix_timestamp: Some(1581534570),
unix_timestamp: Some(1_581_534_570),
epoch: Some(200),
custodian: None,
};
@ -1199,7 +1199,7 @@ fn test_stake_set_lockup() {
let online_custodian_pubkey = online_custodian.pubkey();
let lockup = LockupArgs {
unix_timestamp: Some(1581534571),
unix_timestamp: Some(1_581_534_571),
epoch: Some(201),
custodian: Some(online_custodian_pubkey),
};
@ -1216,7 +1216,7 @@ fn test_stake_set_lockup() {
process_command(&config).unwrap();
let lockup = LockupArgs {
unix_timestamp: Some(1581534572),
unix_timestamp: Some(1_581_534_572),
epoch: Some(202),
custodian: None,
};
@ -1247,7 +1247,7 @@ fn test_stake_set_lockup() {
// Set custodian to offline pubkey
let lockup = LockupArgs {
unix_timestamp: Some(1581534573),
unix_timestamp: Some(1_581_534_573),
epoch: Some(203),
custodian: Some(offline_pubkey),
};
@ -1287,7 +1287,7 @@ fn test_stake_set_lockup() {
// Nonced offline set lockup
let lockup = LockupArgs {
unix_timestamp: Some(1581534576),
unix_timestamp: Some(1_581_534_576),
epoch: Some(222),
custodian: None,
};
@ -1524,8 +1524,8 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
config.command = CliCommand::CreateStakeAccount {
stake_account: 1,
seed: Some(seed.to_string()),
staker: Some(offline_pubkey.into()),
withdrawer: Some(offline_pubkey.into()),
staker: Some(offline_pubkey),
withdrawer: Some(offline_pubkey),
lockup: Lockup::default(),
amount: SpendAmount::Some(50_000),
sign_only: false,