mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Fix clippy lints
This commit is contained in:
@@ -598,9 +598,9 @@ pub fn serve<T: 'static + SlotClock + Clone, E: EthSpec>(
|
|||||||
if allow_keystore_export {
|
if allow_keystore_export {
|
||||||
keystores::export(request, validator_store, task_executor, log)
|
keystores::export(request, validator_store, task_executor, log)
|
||||||
} else {
|
} else {
|
||||||
return Err(warp_utils::reject::custom_bad_request(
|
Err(warp_utils::reject::custom_bad_request(
|
||||||
"keystore export is disabled".to_string(),
|
"keystore export is disabled".to_string(),
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -82,10 +82,12 @@ impl ApiTester {
|
|||||||
let api_secret = ApiSecret::create_or_open(validator_dir.path()).unwrap();
|
let api_secret = ApiSecret::create_or_open(validator_dir.path()).unwrap();
|
||||||
let api_pubkey = api_secret.api_token();
|
let api_pubkey = api_secret.api_token();
|
||||||
|
|
||||||
let mut config = Config::default();
|
let config = Config {
|
||||||
config.validator_dir = validator_dir.path().into();
|
validator_dir: validator_dir.path().into(),
|
||||||
config.secrets_dir = secrets_dir.path().into();
|
secrets_dir: secrets_dir.path().into(),
|
||||||
config.fee_recipient = Some(TEST_DEFAULT_FEE_RECIPIENT);
|
fee_recipient: Some(TEST_DEFAULT_FEE_RECIPIENT),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
let spec = E::default_spec();
|
let spec = E::default_spec();
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ impl ApiTester {
|
|||||||
|
|
||||||
let context = Arc::new(Context {
|
let context = Arc::new(Context {
|
||||||
task_executor: test_runtime.task_executor.clone(),
|
task_executor: test_runtime.task_executor.clone(),
|
||||||
api_secret: api_secret,
|
api_secret,
|
||||||
validator_dir: Some(validator_dir.path().into()),
|
validator_dir: Some(validator_dir.path().into()),
|
||||||
validator_store: Some(validator_store.clone()),
|
validator_store: Some(validator_store.clone()),
|
||||||
spec: E::default_spec(),
|
spec: E::default_spec(),
|
||||||
@@ -131,7 +133,7 @@ impl ApiTester {
|
|||||||
log,
|
log,
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
});
|
});
|
||||||
let ctx = context.clone();
|
let ctx = context;
|
||||||
let (shutdown_tx, shutdown_rx) = oneshot::channel();
|
let (shutdown_tx, shutdown_rx) = oneshot::channel();
|
||||||
let server_shutdown = async {
|
let server_shutdown = async {
|
||||||
// It's not really interesting why this triggered, just that it happened.
|
// It's not really interesting why this triggered, just that it happened.
|
||||||
@@ -166,7 +168,7 @@ impl ApiTester {
|
|||||||
let tmp = tempdir().unwrap();
|
let tmp = tempdir().unwrap();
|
||||||
let api_secret = ApiSecret::create_or_open(tmp.path()).unwrap();
|
let api_secret = ApiSecret::create_or_open(tmp.path()).unwrap();
|
||||||
let invalid_pubkey = api_secret.api_token();
|
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
|
pub async fn test_with_invalid_auth<F, A, T>(self, func: F) -> Self
|
||||||
@@ -308,7 +310,7 @@ impl ApiTester {
|
|||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.data;
|
.data;
|
||||||
(response.validators.clone(), response.mnemonic.clone())
|
(response.validators.clone(), response.mnemonic)
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(response.len(), s.count);
|
assert_eq!(response.len(), s.count);
|
||||||
@@ -343,22 +345,21 @@ impl ApiTester {
|
|||||||
.set_nextaccount(s.key_derivation_path_offset)
|
.set_nextaccount(s.key_derivation_path_offset)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
for i in 0..s.count {
|
for item in response.iter().take(s.count) {
|
||||||
let keypairs = wallet
|
let keypairs = wallet
|
||||||
.next_validator(PASSWORD_BYTES, PASSWORD_BYTES, PASSWORD_BYTES)
|
.next_validator(PASSWORD_BYTES, PASSWORD_BYTES, PASSWORD_BYTES)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let voting_keypair = keypairs.voting.decrypt_keypair(PASSWORD_BYTES).unwrap();
|
let voting_keypair = keypairs.voting.decrypt_keypair(PASSWORD_BYTES).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
response[i].voting_pubkey,
|
item.voting_pubkey,
|
||||||
voting_keypair.pk.clone().into(),
|
voting_keypair.pk.clone().into(),
|
||||||
"the locally generated voting pk should match the server response"
|
"the locally generated voting pk should match the server response"
|
||||||
);
|
);
|
||||||
|
|
||||||
let withdrawal_keypair = keypairs.withdrawal.decrypt_keypair(PASSWORD_BYTES).unwrap();
|
let withdrawal_keypair = keypairs.withdrawal.decrypt_keypair(PASSWORD_BYTES).unwrap();
|
||||||
|
|
||||||
let deposit_bytes =
|
let deposit_bytes = eth2_serde_utils::hex::decode(&item.eth1_deposit_tx_data).unwrap();
|
||||||
eth2_serde_utils::hex::decode(&response[i].eth1_deposit_tx_data).unwrap();
|
|
||||||
|
|
||||||
let (deposit_data, _) =
|
let (deposit_data, _) =
|
||||||
decode_eth1_tx_data(&deposit_bytes, E::default_spec().max_effective_balance)
|
decode_eth1_tx_data(&deposit_bytes, E::default_spec().max_effective_balance)
|
||||||
|
|||||||
@@ -774,8 +774,8 @@ async fn check_get_set_fee_recipient() {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn check_get_set_gas_limit() {
|
async fn check_get_set_gas_limit() {
|
||||||
run_test(|tester: ApiTester| async move {
|
run_test(|tester: ApiTester| async move {
|
||||||
let _ = &tester;
|
let _ = &tester;
|
||||||
let password = random_password_string();
|
let password = random_password_string();
|
||||||
@@ -947,6 +947,7 @@ fn check_get_set_gas_limit() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all_indices(count: usize) -> Vec<usize> {
|
fn all_indices(count: usize) -> Vec<usize> {
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ impl ValidatorSpecification {
|
|||||||
if response
|
if response
|
||||||
.data
|
.data
|
||||||
.iter()
|
.iter()
|
||||||
.find(|validator| validator.validating_pubkey == voting_public_key)
|
.any(|validator| validator.validating_pubkey == voting_public_key)
|
||||||
.is_some()
|
|
||||||
{
|
{
|
||||||
if ignore_duplicates {
|
if ignore_duplicates {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
@@ -278,7 +277,7 @@ mod bytes_4_without_0x_prefix {
|
|||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
let hex_string = &hex::encode(&bytes);
|
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>
|
pub fn deserialize<'de, D>(deserializer: D) -> Result<[u8; BYTES_LEN], D::Error>
|
||||||
|
|||||||
@@ -300,8 +300,7 @@ async fn run<'a>(config: MoveConfig) -> Result<(), String> {
|
|||||||
if response
|
if response
|
||||||
.data
|
.data
|
||||||
.iter()
|
.iter()
|
||||||
.find(|v| v.validating_pubkey == pubkey_to_move)
|
.any(|v| v.validating_pubkey == pubkey_to_move)
|
||||||
.is_some()
|
|
||||||
{
|
{
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"There was an error removing a validator, however the validator \
|
"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));
|
return Err(format!("{:?}", e));
|
||||||
}
|
}
|
||||||
Err(UploadError::DuplicateValidator(_)) => {
|
Err(UploadError::DuplicateValidator(_)) => {
|
||||||
return Err(format!(
|
return Err("Duplicate validator detected when duplicates are ignored".to_string());
|
||||||
"Duplicate validator detected when duplicates are ignored"
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
Err(UploadError::FailedToListKeys(e)) => {
|
Err(UploadError::FailedToListKeys(e)) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|||||||
Reference in New Issue
Block a user