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

@ -183,10 +183,8 @@ mod tests {
// until they reach slots_per_epoch
let slots_in_epoch = epoch_schedule.get_slots_in_epoch(epoch);
if slots_in_epoch != last_slots_in_epoch {
if slots_in_epoch != slots_per_epoch {
assert_eq!(slots_in_epoch, last_slots_in_epoch * 2);
}
if slots_in_epoch != last_slots_in_epoch && slots_in_epoch != slots_per_epoch {
assert_eq!(slots_in_epoch, last_slots_in_epoch * 2);
}
last_slots_in_epoch = slots_in_epoch;
}

View File

@ -67,10 +67,7 @@ mod tests {
hf.register(10);
hf.register(20);
assert_eq!(
hf.iter().map(|i| *i).collect::<Vec<_>>(),
vec![(10, 1), (20, 2), (30, 1)]
);
assert_eq!(hf.hard_forks, vec![(10, 1), (20, 2), (30, 1)]);
}
#[test]

View File

@ -89,6 +89,7 @@ mod tests {
use super::*;
#[test]
#[allow(clippy::float_cmp)]
fn test_inflation_basic() {
let inflation = Inflation::default();

View File

@ -218,7 +218,7 @@ mod test {
// New is in Uninitialzed state
assert_eq!(state, State::Uninitialized);
let recent_blockhashes = create_test_recent_blockhashes(95);
let authorized = keyed_account.unsigned_key().clone();
let authorized = keyed_account.unsigned_key();
keyed_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -228,7 +228,7 @@ mod test {
let data = nonce::state::Data {
blockhash: recent_blockhashes[0].blockhash,
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
..data.clone()
..data
};
// First nonce instruction drives state from Uninitialized to Initialized
assert_eq!(state, State::Initialized(data.clone()));
@ -242,7 +242,7 @@ mod test {
let data = nonce::state::Data {
blockhash: recent_blockhashes[0].blockhash,
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
..data.clone()
..data
};
// Second nonce instruction consumes and replaces stored nonce
assert_eq!(state, State::Initialized(data.clone()));
@ -256,10 +256,10 @@ mod test {
let data = nonce::state::Data {
blockhash: recent_blockhashes[0].blockhash,
fee_calculator: recent_blockhashes[0].fee_calculator.clone(),
..data.clone()
..data
};
// Third nonce instruction for fun and profit
assert_eq!(state, State::Initialized(data.clone()));
assert_eq!(state, State::Initialized(data));
with_test_keyed_account(42, false, |to_keyed| {
let recent_blockhashes = create_test_recent_blockhashes(0);
let withdraw_lamports = keyed_account.account.borrow().lamports;
@ -295,11 +295,11 @@ mod test {
let min_lamports = rent.minimum_balance(State::size());
with_test_keyed_account(min_lamports + 42, true, |nonce_account| {
let recent_blockhashes = create_test_recent_blockhashes(31);
let authority = nonce_account.unsigned_key().clone();
let authority = *nonce_account.unsigned_key();
nonce_account
.initialize_nonce_account(&authority, &recent_blockhashes, &rent)
.unwrap();
let pubkey = nonce_account.account.borrow().owner.clone();
let pubkey = nonce_account.account.borrow().owner;
let nonce_account = KeyedAccount::new(&pubkey, false, nonce_account.account);
let state = AccountUtilsState::<Versions>::state(&nonce_account)
.unwrap()
@ -328,7 +328,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(keyed_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(0);
let authorized = keyed_account.unsigned_key().clone();
let authorized = *keyed_account.unsigned_key();
keyed_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -349,7 +349,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(keyed_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = keyed_account.unsigned_key().clone();
let authorized = *keyed_account.unsigned_key();
keyed_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -386,7 +386,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(nonce_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = nonce_authority.unsigned_key().clone();
let authorized = *nonce_authority.unsigned_key();
nonce_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -411,7 +411,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(nonce_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = nonce_authority.unsigned_key().clone();
let authorized = *nonce_authority.unsigned_key();
nonce_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -586,7 +586,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(nonce_keyed.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(31);
let authority = nonce_keyed.unsigned_key().clone();
let authority = *nonce_keyed.unsigned_key();
nonce_keyed
.initialize_nonce_account(&authority, &recent_blockhashes, &rent)
.unwrap();
@ -653,7 +653,7 @@ mod test {
let min_lamports = rent.minimum_balance(State::size());
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
let recent_blockhashes = create_test_recent_blockhashes(0);
let authorized = nonce_keyed.unsigned_key().clone();
let authorized = *nonce_keyed.unsigned_key();
nonce_keyed
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -682,7 +682,7 @@ mod test {
let min_lamports = rent.minimum_balance(State::size());
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
let recent_blockhashes = create_test_recent_blockhashes(95);
let authorized = nonce_keyed.unsigned_key().clone();
let authorized = *nonce_keyed.unsigned_key();
nonce_keyed
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -712,7 +712,7 @@ mod test {
let min_lamports = rent.minimum_balance(State::size());
with_test_keyed_account(min_lamports + 42, true, |nonce_keyed| {
let recent_blockhashes = create_test_recent_blockhashes(95);
let authorized = nonce_keyed.unsigned_key().clone();
let authorized = *nonce_keyed.unsigned_key();
nonce_keyed
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -748,7 +748,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(keyed_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(0);
let authority = keyed_account.unsigned_key().clone();
let authority = *keyed_account.unsigned_key();
let result =
keyed_account.initialize_nonce_account(&authority, &recent_blockhashes, &rent);
let data = nonce::state::Data {
@ -775,7 +775,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(keyed_account.signer_key().unwrap().clone());
let recent_blockhashes = RecentBlockhashes::from_iter(vec![].into_iter());
let authorized = keyed_account.unsigned_key().clone();
let authorized = *keyed_account.unsigned_key();
let result =
keyed_account.initialize_nonce_account(&authorized, &recent_blockhashes, &rent);
assert_eq!(result, Err(NonceError::NoRecentBlockhashes.into()));
@ -791,7 +791,7 @@ mod test {
let min_lamports = rent.minimum_balance(State::size());
with_test_keyed_account(min_lamports + 42, true, |keyed_account| {
let recent_blockhashes = create_test_recent_blockhashes(31);
let authorized = keyed_account.unsigned_key().clone();
let authorized = *keyed_account.unsigned_key();
keyed_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();
@ -811,7 +811,7 @@ mod test {
let min_lamports = rent.minimum_balance(State::size());
with_test_keyed_account(min_lamports - 42, true, |keyed_account| {
let recent_blockhashes = create_test_recent_blockhashes(63);
let authorized = keyed_account.unsigned_key().clone();
let authorized = *keyed_account.unsigned_key();
let result =
keyed_account.initialize_nonce_account(&authorized, &recent_blockhashes, &rent);
assert_eq!(result, Err(InstructionError::InsufficientFunds));
@ -829,7 +829,7 @@ mod test {
let mut signers = HashSet::new();
signers.insert(nonce_account.signer_key().unwrap().clone());
let recent_blockhashes = create_test_recent_blockhashes(31);
let authorized = nonce_account.unsigned_key().clone();
let authorized = *nonce_account.unsigned_key();
nonce_account
.initialize_nonce_account(&authorized, &recent_blockhashes, &rent)
.unwrap();

View File

@ -396,7 +396,7 @@ mod tests {
let out_dir = env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());
let keypair = Keypair::new();
format!("{}/tmp/{}-{}", out_dir, name, keypair.pubkey()).to_string()
format!("{}/tmp/{}-{}", out_dir, name, keypair.pubkey())
}
#[test]

View File

@ -141,6 +141,7 @@ mod tests {
}
#[test]
#[allow(clippy::blacklisted_name)]
fn test_dyn_keypairs_by_ref_compile() {
let foo = Foo {};
let bar = Bar {};

View File

@ -167,6 +167,7 @@ mod tests {
use rand::thread_rng;
#[test]
#[allow(clippy::assertions_on_constants)]
fn test_sysvar_can_hold_all_active_blockhashes() {
// Ensure we can still hold all of the active entries in `BlockhashQueue`
assert!(MAX_PROCESSING_AGE <= MAX_ENTRIES);

View File

@ -52,6 +52,7 @@ mod test {
use super::*;
#[test]
#[allow(clippy::float_cmp)]
fn test_years_as_slots() {
let tick_duration = Duration::from_micros(1000 * 1000 / 160);

View File

@ -526,7 +526,7 @@ mod tests {
tx.message.account_keys.resize(4, Pubkey::default());
assert_eq!(tx.sanitize(), Err(SanitizeError::IndexOutOfBounds));
tx = o.clone();
tx = o;
tx.message.header.num_readonly_signed_accounts = 2;
tx.message.header.num_required_signatures = 1;
assert_eq!(tx.sanitize(), Err(SanitizeError::IndexOutOfBounds));