From e9c06d0b17aa667e1f666481cd721006f6121fb0 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 18 May 2021 08:25:51 -0500 Subject: [PATCH 1/2] tests: cleanup test --- runtime/src/accounts_index.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 87c0efaded732f..3a760b406ec2bb 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -2203,6 +2203,7 @@ pub mod tests { #[test] fn test_insert_new_with_lock_no_ancestors() { let key = Keypair::new(); + let pubkey = &key.pubkey(); let mut gc = Vec::new(); let slot = 0; @@ -2222,15 +2223,15 @@ pub mod tests { assert!(index.zero_lamport_pubkeys().is_empty()); let mut ancestors = Ancestors::default(); - assert!(index.get(&key.pubkey(), Some(&ancestors), None).is_none()); - assert!(index.get(&key.pubkey(), None, None).is_none()); + assert!(index.get(&pubkey, Some(&ancestors), None).is_none()); + assert!(index.get(&pubkey, None, None).is_none()); let mut num = 0; index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1); assert_eq!(num, 0); ancestors.insert(slot, 0); - assert!(index.get(&key.pubkey(), Some(&ancestors), None).is_some()); - assert_eq!(index.ref_count_from_storage(&key.pubkey()), 1); + assert!(index.get(&pubkey, Some(&ancestors), None).is_some()); + assert_eq!(index.ref_count_from_storage(&pubkey), 1); index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1); assert_eq!(num, 1); @@ -2252,15 +2253,15 @@ pub mod tests { assert!(!index.zero_lamport_pubkeys().is_empty()); let mut ancestors = Ancestors::default(); - assert!(index.get(&key.pubkey(), Some(&ancestors), None).is_none()); - assert!(index.get(&key.pubkey(), None, None).is_none()); + assert!(index.get(&pubkey, Some(&ancestors), None).is_none()); + assert!(index.get(&pubkey, None, None).is_none()); let mut num = 0; index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1); assert_eq!(num, 0); ancestors.insert(slot, 0); - assert!(index.get(&key.pubkey(), Some(&ancestors), None).is_some()); - assert_eq!(index.ref_count_from_storage(&key.pubkey()), 0); // cached, so 0 + assert!(index.get(&pubkey, Some(&ancestors), None).is_some()); + assert_eq!(index.ref_count_from_storage(&pubkey), 0); // cached, so 0 index.unchecked_scan_accounts("", &ancestors, |_pubkey, _index| num += 1); assert_eq!(num, 1); } From c697217ccb2fbd6738a25fc6ffdd4b1014613959 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 18 May 2021 13:25:02 -0500 Subject: [PATCH 2/2] 2 more replacements --- runtime/src/accounts_index.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 3a760b406ec2bb..85708983d9d78b 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -2212,7 +2212,7 @@ pub mod tests { let account_info = true; index.insert_new_if_missing_into_primary_index( slot, - &key.pubkey(), + pubkey, account_info, &mut gc, &mut w_account_maps, @@ -2242,7 +2242,7 @@ pub mod tests { let account_info: AccountInfoTest = 0 as AccountInfoTest; index.insert_new_if_missing_into_primary_index( slot, - &key.pubkey(), + pubkey, account_info, &mut gc, &mut w_account_maps,