Fix test failure
This commit is contained in:
		| @@ -686,19 +686,16 @@ impl AccountsDB { | ||||
|                 { | ||||
|                     if parent_fork != fork { | ||||
|                         self.insert_account_entry(fork, id, offset, &map); | ||||
|                         if self.remove_account_entries(&parents, &map) { | ||||
|                             keys.push(pubkey.clone()); | ||||
|                         } | ||||
|                     } | ||||
|                     let account = self.get_account(id, offset); | ||||
|                     if account.tokens == 0 { | ||||
|                         if self.remove_account_entries(&[fork], &map) { | ||||
|                             keys.push(pubkey.clone()); | ||||
|                         } | ||||
|                         if vote_program::check_id(&account.owner) { | ||||
|                             self.index_info.vote_index.write().unwrap().remove(pubkey); | ||||
|                         } | ||||
|                     } else { | ||||
|                         let account = self.get_account(id, offset); | ||||
|                         if account.tokens == 0 { | ||||
|                             if self.remove_account_entries(&[fork], &map) { | ||||
|                                 keys.push(pubkey.clone()); | ||||
|                             } | ||||
|                             if vote_program::check_id(&account.owner) { | ||||
|                                 self.index_info.vote_index.write().unwrap().remove(pubkey); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             }); | ||||
| @@ -759,12 +756,16 @@ impl Accounts { | ||||
|  | ||||
|     /// Slow because lock is held for 1 operation insted of many | ||||
|     pub fn load_slow(&self, fork: Fork, pubkey: &Pubkey) -> Option<Account> { | ||||
|         self.accounts_db.load(fork, pubkey, true).filter(|acc| acc.tokens != 0) | ||||
|         self.accounts_db | ||||
|             .load(fork, pubkey, true) | ||||
|             .filter(|acc| acc.tokens != 0) | ||||
|     } | ||||
|  | ||||
|     /// Slow because lock is held for 1 operation insted of many | ||||
|     pub fn load_slow_no_parent(&self, fork: Fork, pubkey: &Pubkey) -> Option<Account> { | ||||
|         self.accounts_db.load(fork, pubkey, false).filter(|acc| acc.tokens != 0) | ||||
|         self.accounts_db | ||||
|             .load(fork, pubkey, false) | ||||
|             .filter(|acc| acc.tokens != 0) | ||||
|     } | ||||
|  | ||||
|     /// Slow because lock is held for 1 operation insted of many | ||||
| @@ -1346,11 +1347,12 @@ mod tests { | ||||
|         assert_eq!(db.load(1, &key, true), None); | ||||
|         for _ in 1..100 { | ||||
|             let idx = thread_rng().gen_range(0, 99); | ||||
|             assert_eq!(db.load(0, &pubkeys[idx], true), None); | ||||
|             let account = db.load(1, &pubkeys[idx], true).unwrap(); | ||||
|             let account0 = db.load(0, &pubkeys[idx], true).unwrap(); | ||||
|             let account1 = db.load(1, &pubkeys[idx], true).unwrap(); | ||||
|             let mut default_account = Account::default(); | ||||
|             default_account.tokens = (idx + 1) as u64; | ||||
|             assert_eq!(compare_account(&default_account, &account), true); | ||||
|             assert_eq!(compare_account(&default_account, &account0), true); | ||||
|             assert_eq!(compare_account(&default_account, &account1), true); | ||||
|         } | ||||
|         cleanup_dirs(&paths); | ||||
|     } | ||||
|   | ||||
| @@ -475,7 +475,8 @@ mod tests { | ||||
|             Blocktree::open(&ledger_path).expect("Expected to successfully open database ledger"); | ||||
|         blocktree.write_entries(1, 0, 0, &entries).unwrap(); | ||||
|         let entry_height = genesis_block.ticks_per_slot + entries.len() as u64; | ||||
|         let (bank_forks, bank_forks_info) = process_blocktree(&genesis_block, &blocktree, None).unwrap(); | ||||
|         let (bank_forks, bank_forks_info) = | ||||
|             process_blocktree(&genesis_block, &blocktree, None).unwrap(); | ||||
|  | ||||
|         assert_eq!(bank_forks_info.len(), 1); | ||||
|         assert_eq!( | ||||
|   | ||||
| @@ -746,7 +746,8 @@ mod tests { | ||||
|  | ||||
|         // Close the validator so that rocksdb has locks available | ||||
|         validator_exit(); | ||||
|         let (bank_forks, bank_forks_info, _, _) = new_banks_from_blocktree(&validator_ledger_path, None); | ||||
|         let (bank_forks, bank_forks_info, _, _) = | ||||
|             new_banks_from_blocktree(&validator_ledger_path, None); | ||||
|         let bank = bank_forks.working_bank(); | ||||
|         let entry_height = bank_forks_info[0].entry_height; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user