From 1eef82ef680bd8f9e07543cedef368c924223f5b Mon Sep 17 00:00:00 2001 From: Rory Harris Date: Fri, 1 Aug 2025 13:26:35 -0700 Subject: [PATCH 1/2] Changing is_cached for bool values in the accounts index tests to return the !type --- accounts-db/src/accounts_index.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index 8cb58cae94755b..c84b5c6fb50647 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -2128,12 +2128,12 @@ pub mod tests { #[test] fn test_clean_and_unref_rooted_entries_by_bin_with_reclaim() { - let index = AccountsIndex::::default_for_tests(); + let index = AccountsIndex::::default_for_tests(); let pubkey = solana_pubkey::new_rand(); let slot1 = 0; let slot2 = 1; - let account_info1 = true; - let account_info2 = false; + let account_info1 = 0; + let account_info2 = 1; let mut gc = Vec::new(); for (slot, account_info) in [(slot1, account_info1), (slot2, account_info2)] { @@ -2400,7 +2400,7 @@ pub mod tests { test_new_entry_code_paths_helper([1.0, 2.0], true, *is_upsert, use_disk); // account_info type that is NOT cached - test_new_entry_code_paths_helper([true, false], false, *is_upsert, use_disk); + test_new_entry_code_paths_helper([1, 2], false, *is_upsert, use_disk); } } } @@ -2746,7 +2746,7 @@ pub mod tests { #[test] fn test_update_last_wins() { let key = solana_pubkey::new_rand(); - let index = AccountsIndex::::default_for_tests(); + let index = AccountsIndex::::default_for_tests(); let ancestors = vec![(0, 0)].into_iter().collect(); let mut gc = Vec::new(); index.upsert( @@ -2755,7 +2755,7 @@ pub mod tests { &key, &AccountSharedData::default(), &AccountSecondaryIndexes::default(), - true, + 1, &mut gc, UPSERT_POPULATE_RECLAIMS, ); @@ -2768,7 +2768,7 @@ pub mod tests { false, |(slot, account_info)| { assert_eq!(slot, 0); - assert!(account_info); + assert_eq!(account_info, 1); }, ) .unwrap(); @@ -2780,11 +2780,11 @@ pub mod tests { &key, &AccountSharedData::default(), &AccountSecondaryIndexes::default(), - false, + 0, &mut gc, UPSERT_POPULATE_RECLAIMS, ); - assert_eq!(gc, vec![(0, true)]); + assert_eq!(gc, vec![(0, 1)]); index .get_with_and_then( &key, @@ -2793,7 +2793,7 @@ pub mod tests { false, |(slot, account_info)| { assert_eq!(slot, 0); - assert!(!account_info); + assert_eq!(account_info, 0); }, ) .unwrap(); @@ -3493,7 +3493,7 @@ pub mod tests { impl DiskIndexValue for u64 {} impl IsCached for bool { fn is_cached(&self) -> bool { - false + !*self } } impl IsCached for u64 { From 9d9e55b3ddede06307f9239f331aa0dd8c766c0d Mon Sep 17 00:00:00 2001 From: Rory Harris Date: Tue, 5 Aug 2025 14:52:02 -0700 Subject: [PATCH 2/2] Leave Boolean type alone. Proceed with changing tests to use integer types --- accounts-db/src/accounts_index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index c84b5c6fb50647..5eb7b144b1d7ee 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -3493,7 +3493,7 @@ pub mod tests { impl DiskIndexValue for u64 {} impl IsCached for bool { fn is_cached(&self) -> bool { - !*self + false } } impl IsCached for u64 {