Fix clippy lints

This commit is contained in:
Paul Hauner
2022-08-24 17:46:46 +10:00
parent d20e65a271
commit 43b16b138d
5 changed files with 22 additions and 24 deletions

View File

@@ -598,9 +598,9 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
if allow_keystore_export {
keystores::export(request, validator_store, task_executor, log)
} else {
return Err(warp_utils::reject::custom_bad_request(
Err(warp_utils::reject::custom_bad_request(
"keystore export is disabled".to_string(),
));
))
}
})
},

View File

@@ -82,10 +82,12 @@ impl ApiTester {
let api_secret = ApiSecret::create_or_open(validator_dir.path()).unwrap();
let api_pubkey = api_secret.api_token();
let mut config = Config::default();
config.validator_dir = validator_dir.path().into();
config.secrets_dir = secrets_dir.path().into();
config.fee_recipient = Some(TEST_DEFAULT_FEE_RECIPIENT);
let config = Config {
validator_dir: validator_dir.path().into(),
secrets_dir: secrets_dir.path().into(),
fee_recipient: Some(TEST_DEFAULT_FEE_RECIPIENT),
..Default::default()
};
let spec = E::default_spec();
@@ -117,7 +119,7 @@ impl ApiTester {
let context = Arc::new(Context {
task_executor: test_runtime.task_executor.clone(),
api_secret: api_secret,
api_secret,
validator_dir: Some(validator_dir.path().into()),
validator_store: Some(validator_store.clone()),
spec: E::default_spec(),
@@ -131,7 +133,7 @@ impl ApiTester {
log,
_phantom: PhantomData,
});
let ctx = context.clone();
let ctx = context;
let (shutdown_tx, shutdown_rx) = oneshot::channel();
let server_shutdown = async {
// It's not really interesting why this triggered, just that it happened.
@@ -166,7 +168,7 @@ impl ApiTester {
let tmp = tempdir().unwrap();
let api_secret = ApiSecret::create_or_open(tmp.path()).unwrap();
let invalid_pubkey = api_secret.api_token();
ValidatorClientHttpClient::new(self.url.clone(), invalid_pubkey.clone()).unwrap()
ValidatorClientHttpClient::new(self.url.clone(), invalid_pubkey).unwrap()
}
pub async fn test_with_invalid_auth<F, A, T>(self, func: F) -> Self
@@ -308,7 +310,7 @@ impl ApiTester {
.await
.unwrap()
.data;
(response.validators.clone(), response.mnemonic.clone())
(response.validators.clone(), response.mnemonic)
};
assert_eq!(response.len(), s.count);
@@ -343,22 +345,21 @@ impl ApiTester {
.set_nextaccount(s.key_derivation_path_offset)
.unwrap();
for i in 0..s.count {
for item in response.iter().take(s.count) {
let keypairs = wallet
.next_validator(PASSWORD_BYTES, PASSWORD_BYTES, PASSWORD_BYTES)
.unwrap();
let voting_keypair = keypairs.voting.decrypt_keypair(PASSWORD_BYTES).unwrap();
assert_eq!(
response[i].voting_pubkey,
item.voting_pubkey,
voting_keypair.pk.clone().into(),
"the locally generated voting pk should match the server response"
);
let withdrawal_keypair = keypairs.withdrawal.decrypt_keypair(PASSWORD_BYTES).unwrap();
let deposit_bytes =
eth2_serde_utils::hex::decode(&response[i].eth1_deposit_tx_data).unwrap();
let deposit_bytes = eth2_serde_utils::hex::decode(&item.eth1_deposit_tx_data).unwrap();
let (deposit_data, _) =
decode_eth1_tx_data(&deposit_bytes, E::default_spec().max_effective_balance)

View File

@@ -774,8 +774,8 @@ async fn check_get_set_fee_recipient() {
.await;
}
#[test]
fn check_get_set_gas_limit() {
#[tokio::test]
async fn check_get_set_gas_limit() {
run_test(|tester: ApiTester| async move {
let _ = &tester;
let password = random_password_string();
@@ -947,6 +947,7 @@ fn check_get_set_gas_limit() {
);
}
})
.await
}
fn all_indices(count: usize) -> Vec<usize> {

View File

@@ -80,8 +80,7 @@ impl ValidatorSpecification {
if response
.data
.iter()
.find(|validator| validator.validating_pubkey == voting_public_key)
.is_some()
.any(|validator| validator.validating_pubkey == voting_public_key)
{
if ignore_duplicates {
eprintln!(
@@ -278,7 +277,7 @@ mod bytes_4_without_0x_prefix {
S: serde::Serializer,
{
let hex_string = &hex::encode(&bytes);
serializer.serialize_str(&hex_string)
serializer.serialize_str(hex_string)
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<[u8; BYTES_LEN], D::Error>

View File

@@ -300,8 +300,7 @@ async fn run<'a>(config: MoveConfig) -> Result<(), String> {
if response
.data
.iter()
.find(|v| v.validating_pubkey == pubkey_to_move)
.is_some()
.any(|v| v.validating_pubkey == pubkey_to_move)
{
eprintln!(
"There was an error removing a validator, however the validator \
@@ -434,9 +433,7 @@ async fn run<'a>(config: MoveConfig) -> Result<(), String> {
return Err(format!("{:?}", e));
}
Err(UploadError::DuplicateValidator(_)) => {
return Err(format!(
"Duplicate validator detected when duplicates are ignored"
));
return Err("Duplicate validator detected when duplicates are ignored".to_string());
}
Err(UploadError::FailedToListKeys(e)) => {
eprintln!(