Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 58ef02f

Browse files
authored
9951 clippy errors in the test suite (#10030)
automerge
1 parent 1da1667 commit 58ef02f

File tree

106 files changed

+713
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+713
-827
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clap-utils/src/input_parsers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,16 @@ mod tests {
349349
let matches = app()
350350
.clone()
351351
.get_matches_from(vec!["test", "--single", "50"]);
352-
assert_eq!(lamports_of_sol(&matches, "single"), Some(50000000000));
352+
assert_eq!(lamports_of_sol(&matches, "single"), Some(50_000_000_000));
353353
assert_eq!(lamports_of_sol(&matches, "multiple"), None);
354354
let matches = app()
355355
.clone()
356356
.get_matches_from(vec!["test", "--single", "1.5"]);
357-
assert_eq!(lamports_of_sol(&matches, "single"), Some(1500000000));
357+
assert_eq!(lamports_of_sol(&matches, "single"), Some(1_500_000_000));
358358
assert_eq!(lamports_of_sol(&matches, "multiple"), None);
359359
let matches = app()
360360
.clone()
361361
.get_matches_from(vec!["test", "--single", "0.03"]);
362-
assert_eq!(lamports_of_sol(&matches, "single"), Some(30000000));
362+
assert_eq!(lamports_of_sol(&matches, "single"), Some(30_000_000));
363363
}
364364
}

cli/src/checks.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ mod tests {
9797
let mut mocks = HashMap::new();
9898
mocks.insert(RpcRequest::GetBalance, account_balance_response.clone());
9999
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
100-
assert_eq!(
101-
check_account_for_fee(&rpc_client, &pubkey, &fee_calculator, &message0).unwrap(),
102-
()
103-
);
100+
check_account_for_fee(&rpc_client, &pubkey, &fee_calculator, &message0)
101+
.expect("unexpected result");
104102

105103
let mut mocks = HashMap::new();
106104
mocks.insert(RpcRequest::GetBalance, account_balance_response.clone());
@@ -128,16 +126,13 @@ mod tests {
128126
mocks.insert(RpcRequest::GetBalance, account_balance_response);
129127
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
130128

131-
assert_eq!(
132-
check_account_for_multiple_fees(
133-
&rpc_client,
134-
&pubkey,
135-
&fee_calculator,
136-
&[&message0, &message0]
137-
)
138-
.unwrap(),
139-
()
140-
);
129+
check_account_for_multiple_fees(
130+
&rpc_client,
131+
&pubkey,
132+
&fee_calculator,
133+
&[&message0, &message0],
134+
)
135+
.expect("unexpected result");
141136
}
142137

143138
#[test]
@@ -194,19 +189,14 @@ mod tests {
194189
#[test]
195190
fn test_check_unique_pubkeys() {
196191
let pubkey0 = Pubkey::new_rand();
197-
let pubkey_clone = pubkey0.clone();
192+
let pubkey_clone = pubkey0;
198193
let pubkey1 = Pubkey::new_rand();
199194

200-
assert_eq!(
201-
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
202-
.unwrap(),
203-
()
204-
);
205-
assert_eq!(
206-
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "foo".to_string()))
207-
.unwrap(),
208-
()
209-
);
195+
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "bar".to_string()))
196+
.expect("unexpected result");
197+
check_unique_pubkeys((&pubkey0, "foo".to_string()), (&pubkey1, "foo".to_string()))
198+
.expect("unexpected result");
199+
210200
assert!(check_unique_pubkeys(
211201
(&pubkey0, "foo".to_string()),
212202
(&pubkey_clone, "bar".to_string())

cli/src/cli.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,7 @@ mod tests {
27032703
}
27042704

27052705
#[test]
2706+
#[allow(clippy::cognitive_complexity)]
27062707
fn test_cli_parse_command() {
27072708
let test_commands = app("test", "desc", "version");
27082709

@@ -2800,7 +2801,7 @@ mod tests {
28002801
);
28012802

28022803
// Test Confirm Subcommand
2803-
let signature = Signature::new(&vec![1; 64]);
2804+
let signature = Signature::new(&[1; 64]);
28042805
let signature_string = format!("{:?}", signature);
28052806
let test_confirm =
28062807
test_commands
@@ -3235,6 +3236,7 @@ mod tests {
32353236
}
32363237

32373238
#[test]
3239+
#[allow(clippy::cognitive_complexity)]
32383240
fn test_cli_process_command() {
32393241
// Success cases
32403242
let mut config = CliConfig::default();
@@ -3774,7 +3776,7 @@ mod tests {
37743776
blockhash_query::Source::NonceAccount(nonce_address),
37753777
blockhash
37763778
),
3777-
nonce_account: Some(nonce_address.into()),
3779+
nonce_account: Some(nonce_address),
37783780
nonce_authority: 1,
37793781
fee_payer: 0,
37803782
},

cli/src/offline/blockhash_query.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,19 @@ mod tests {
303303
);
304304
mocks.insert(
305305
RpcRequest::GetFeeCalculatorForBlockhash,
306-
get_fee_calculator_for_blockhash_response.clone(),
306+
get_fee_calculator_for_blockhash_response,
307307
);
308308
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
309309
assert_eq!(
310310
BlockhashQuery::FeeCalculator(Source::Cluster, test_blockhash)
311311
.get_blockhash_and_fee_calculator(&rpc_client)
312312
.unwrap(),
313-
(test_blockhash, rpc_fee_calc.clone()),
313+
(test_blockhash, rpc_fee_calc),
314314
);
315315
let mut mocks = HashMap::new();
316316
mocks.insert(
317317
RpcRequest::GetRecentBlockhash,
318-
get_recent_blockhash_response.clone(),
318+
get_recent_blockhash_response,
319319
);
320320
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
321321
assert_eq!(
@@ -347,7 +347,7 @@ mod tests {
347347
let rpc_nonce_account = RpcAccount::encode(nonce_account);
348348
let get_account_response = json!(Response {
349349
context: RpcResponseContext { slot: 1 },
350-
value: json!(Some(rpc_nonce_account.clone())),
350+
value: json!(Some(rpc_nonce_account)),
351351
});
352352

353353
let mut mocks = HashMap::new();
@@ -366,7 +366,7 @@ mod tests {
366366
BlockhashQuery::FeeCalculator(Source::NonceAccount(nonce_pubkey), nonce_blockhash)
367367
.get_blockhash_and_fee_calculator(&rpc_client)
368368
.unwrap(),
369-
(nonce_blockhash, nonce_fee_calc.clone()),
369+
(nonce_blockhash, nonce_fee_calc),
370370
);
371371
let mut mocks = HashMap::new();
372372
mocks.insert(RpcRequest::GetAccountInfo, get_account_response.clone());
@@ -377,7 +377,7 @@ mod tests {
377377
.is_err()
378378
);
379379
let mut mocks = HashMap::new();
380-
mocks.insert(RpcRequest::GetAccountInfo, get_account_response.clone());
380+
mocks.insert(RpcRequest::GetAccountInfo, get_account_response);
381381
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
382382
assert_eq!(
383383
BlockhashQuery::None(nonce_blockhash)

cli/src/stake.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,7 @@ mod tests {
14821482
}
14831483

14841484
#[test]
1485+
#[allow(clippy::cognitive_complexity)]
14851486
fn test_parse_command() {
14861487
let test_commands = app("test", "desc", "version");
14871488
let default_keypair = Keypair::new();
@@ -2861,7 +2862,7 @@ mod tests {
28612862
blockhash_query::Source::NonceAccount(nonce_account),
28622863
nonce_hash
28632864
),
2864-
nonce_account: Some(nonce_account.into()),
2865+
nonce_account: Some(nonce_account),
28652866
nonce_authority: 1,
28662867
split_stake_account: 2,
28672868
seed: None,

cli/src/validator_info.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,7 @@ mod tests {
508508
let mut info = Map::new();
509509
info.insert("name".to_string(), Value::String("Alice".to_string()));
510510
let info_string = serde_json::to_string(&Value::Object(info.clone())).unwrap();
511-
let validator_info = ValidatorInfo {
512-
info: info_string.clone(),
513-
};
511+
let validator_info = ValidatorInfo { info: info_string };
514512
let data = serialize(&(config, validator_info)).unwrap();
515513

516514
assert_eq!(
@@ -547,9 +545,7 @@ mod tests {
547545
info.insert("details".to_string(), Value::String(max_long_string));
548546
let info_string = serde_json::to_string(&Value::Object(info)).unwrap();
549547

550-
let validator_info = ValidatorInfo {
551-
info: info_string.clone(),
552-
};
548+
let validator_info = ValidatorInfo { info: info_string };
553549

554550
assert_eq!(
555551
serialized_size(&validator_info).unwrap(),

cli/tests/stake.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ fn test_offline_stake_delegation_and_deactivation() {
354354
config_validator.command = CliCommand::CreateStakeAccount {
355355
stake_account: 1,
356356
seed: None,
357-
staker: Some(config_offline.signers[0].pubkey().into()),
357+
staker: Some(config_offline.signers[0].pubkey()),
358358
withdrawer: None,
359359
lockup: Lockup::default(),
360360
amount: SpendAmount::Some(50_000),
@@ -1033,7 +1033,7 @@ fn test_stake_split() {
10331033
check_balance(0, &rpc_client, &split_account.pubkey());
10341034
config_offline.signers.push(&split_account);
10351035
config_offline.command = CliCommand::SplitStake {
1036-
stake_account_pubkey: stake_account_pubkey,
1036+
stake_account_pubkey,
10371037
stake_authority: 0,
10381038
sign_only: true,
10391039
blockhash_query: BlockhashQuery::None(nonce_hash),
@@ -1051,7 +1051,7 @@ fn test_stake_split() {
10511051
let offline_presigner = sign_only.presigner_of(&offline_pubkey).unwrap();
10521052
config.signers = vec![&offline_presigner, &split_account];
10531053
config.command = CliCommand::SplitStake {
1054-
stake_account_pubkey: stake_account_pubkey,
1054+
stake_account_pubkey,
10551055
stake_authority: 0,
10561056
sign_only: false,
10571057
blockhash_query: BlockhashQuery::FeeCalculator(
@@ -1165,7 +1165,7 @@ fn test_stake_set_lockup() {
11651165

11661166
// Online set lockup
11671167
let lockup = LockupArgs {
1168-
unix_timestamp: Some(1581534570),
1168+
unix_timestamp: Some(1_581_534_570),
11691169
epoch: Some(200),
11701170
custodian: None,
11711171
};
@@ -1199,7 +1199,7 @@ fn test_stake_set_lockup() {
11991199
let online_custodian_pubkey = online_custodian.pubkey();
12001200

12011201
let lockup = LockupArgs {
1202-
unix_timestamp: Some(1581534571),
1202+
unix_timestamp: Some(1_581_534_571),
12031203
epoch: Some(201),
12041204
custodian: Some(online_custodian_pubkey),
12051205
};
@@ -1216,7 +1216,7 @@ fn test_stake_set_lockup() {
12161216
process_command(&config).unwrap();
12171217

12181218
let lockup = LockupArgs {
1219-
unix_timestamp: Some(1581534572),
1219+
unix_timestamp: Some(1_581_534_572),
12201220
epoch: Some(202),
12211221
custodian: None,
12221222
};
@@ -1247,7 +1247,7 @@ fn test_stake_set_lockup() {
12471247

12481248
// Set custodian to offline pubkey
12491249
let lockup = LockupArgs {
1250-
unix_timestamp: Some(1581534573),
1250+
unix_timestamp: Some(1_581_534_573),
12511251
epoch: Some(203),
12521252
custodian: Some(offline_pubkey),
12531253
};
@@ -1287,7 +1287,7 @@ fn test_stake_set_lockup() {
12871287

12881288
// Nonced offline set lockup
12891289
let lockup = LockupArgs {
1290-
unix_timestamp: Some(1581534576),
1290+
unix_timestamp: Some(1_581_534_576),
12911291
epoch: Some(222),
12921292
custodian: None,
12931293
};
@@ -1524,8 +1524,8 @@ fn test_offline_nonced_create_stake_account_and_withdraw() {
15241524
config.command = CliCommand::CreateStakeAccount {
15251525
stake_account: 1,
15261526
seed: Some(seed.to_string()),
1527-
staker: Some(offline_pubkey.into()),
1528-
withdrawer: Some(offline_pubkey.into()),
1527+
staker: Some(offline_pubkey),
1528+
withdrawer: Some(offline_pubkey),
15291529
lockup: Lockup::default(),
15301530
amount: SpendAmount::Some(50_000),
15311531
sign_only: false,

client/src/rpc_client.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,6 @@ mod tests {
10571057
use jsonrpc_core::{Error, IoHandler, Params};
10581058
use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder};
10591059
use serde_json::Number;
1060-
use solana_logger;
10611060
use solana_sdk::{
10621061
instruction::InstructionError, signature::Keypair, system_transaction,
10631062
transaction::TransactionError,

client/src/rpc_request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ mod tests {
151151
assert_eq!(request["method"], "getRecentBlockhash");
152152

153153
let test_request = RpcRequest::GetFeeCalculatorForBlockhash;
154-
let request = test_request.build_request_json(1, json!([addr.clone()]));
154+
let request = test_request.build_request_json(1, json!([addr]));
155155
assert_eq!(request["method"], "getFeeCalculatorForBlockhash");
156156

157157
let test_request = RpcRequest::GetFeeRateGovernor;

0 commit comments

Comments
 (0)