Rust 1.54.0 lints (#2483)

## Issue Addressed

N/A

## Proposed Changes

- Removing a bunch of unnecessary references
- Updated `Error::VariantError` to `Error::Variant`
- There were additional enum variant lints that I ignored, because I thought our variant names were fine
- removed `MonitoredValidator`'s `pubkey` field, because I couldn't find it used anywhere. It looks like we just use the string version of the pubkey (the `id` field) if there is no index

## Additional Info



Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
realbigsean
2021-07-30 01:11:47 +00:00
parent 8efd9fc324
commit 303deb9969
104 changed files with 307 additions and 313 deletions

View File

@@ -377,7 +377,7 @@ pub fn encrypt(
password.retain(|c| !is_control_character(c));
let derived_key = derive_key(&password.as_ref(), &kdf)?;
let derived_key = derive_key(password.as_ref(), kdf)?;
// Encrypt secret.
let mut cipher_text = plain_text.to_vec();
@@ -389,7 +389,7 @@ pub fn encrypt(
// AES Encrypt
let key = GenericArray::from_slice(&derived_key.as_bytes()[0..16]);
let nonce = GenericArray::from_slice(params.iv.as_bytes());
let mut cipher = AesCtr::new(&key, &nonce);
let mut cipher = AesCtr::new(key, nonce);
cipher.apply_keystream(&mut cipher_text);
}
};
@@ -435,7 +435,7 @@ pub fn decrypt(password: &[u8], crypto: &Crypto) -> Result<PlainText, Error> {
// AES Decrypt
let key = GenericArray::from_slice(&derived_key.as_bytes()[0..16]);
let nonce = GenericArray::from_slice(params.iv.as_bytes());
let mut cipher = AesCtr::new(&key, &nonce);
let mut cipher = AesCtr::new(key, nonce);
cipher.apply_keystream(plain_text.as_mut_bytes());
}
};

View File

@@ -41,7 +41,7 @@ fn scrypt_reference() {
}
"#;
assert!(Keystore::from_json_str(&vector).is_ok());
assert!(Keystore::from_json_str(vector).is_ok());
}
#[test]
@@ -79,7 +79,7 @@ fn pbkdf2_reference() {
}
"#;
assert!(Keystore::from_json_str(&vector).is_ok());
assert!(Keystore::from_json_str(vector).is_ok());
}
#[test]
@@ -119,7 +119,7 @@ fn additional_top_level_key() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -162,7 +162,7 @@ fn additional_cipher_key() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -205,7 +205,7 @@ fn additional_checksum_key() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -248,7 +248,7 @@ fn additional_kdf_key() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -291,7 +291,7 @@ fn additional_crypto_key() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -333,7 +333,7 @@ fn bad_version() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -377,7 +377,7 @@ fn json_bad_checksum() {
"#;
assert_eq!(
Keystore::from_json_str(&vector)
Keystore::from_json_str(vector)
.unwrap()
.decrypt_keypair("testpassword".as_bytes())
.err()
@@ -422,7 +422,7 @@ fn kdf_function() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -463,7 +463,7 @@ fn missing_scrypt_param() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -506,7 +506,7 @@ fn additional_scrypt_param() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -548,7 +548,7 @@ fn checksum_function() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -592,7 +592,7 @@ fn checksum_params() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -634,7 +634,7 @@ fn kdf_message() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -676,7 +676,7 @@ fn cipher_function() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -719,7 +719,7 @@ fn additional_cipher_param() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -759,7 +759,7 @@ fn missing_cipher_param() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -800,7 +800,7 @@ fn missing_pubkey() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -841,7 +841,7 @@ fn missing_path() {
}
"#;
assert!(Keystore::from_json_str(&vector).is_ok());
assert!(Keystore::from_json_str(vector).is_ok());
}
#[test]
@@ -879,7 +879,7 @@ fn missing_version() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -920,7 +920,7 @@ fn pbkdf2_bad_hmac() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -962,7 +962,7 @@ fn pbkdf2_additional_parameter() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -1002,7 +1002,7 @@ fn pbkdf2_missing_parameter() {
}
"#;
match Keystore::from_json_str(&vector) {
match Keystore::from_json_str(vector) {
Err(Error::InvalidJson(_)) => {}
_ => panic!("expected invalid json error"),
}
@@ -1045,5 +1045,5 @@ fn name_field() {
}
"#;
assert!(Keystore::from_json_str(&vector).is_ok());
assert!(Keystore::from_json_str(vector).is_ok());
}

View File

@@ -5,7 +5,7 @@ use eth2_keystore::{Error, Keystore};
const PASSWORD: &str = "testpassword";
fn decrypt_error(vector: &str) -> Error {
Keystore::from_json_str(&vector)
Keystore::from_json_str(vector)
.unwrap()
.decrypt_keypair(PASSWORD.as_bytes())
.err()