Fix test failure
This commit is contained in:
parent
c241a56fb0
commit
ca0f16ccc0
|
@ -686,19 +686,16 @@ impl AccountsDB {
|
||||||
{
|
{
|
||||||
if parent_fork != fork {
|
if parent_fork != fork {
|
||||||
self.insert_account_entry(fork, id, offset, &map);
|
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 {
|
} 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
|
/// Slow because lock is held for 1 operation insted of many
|
||||||
pub fn load_slow(&self, fork: Fork, pubkey: &Pubkey) -> Option<Account> {
|
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
|
/// Slow because lock is held for 1 operation insted of many
|
||||||
pub fn load_slow_no_parent(&self, fork: Fork, pubkey: &Pubkey) -> Option<Account> {
|
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
|
/// 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);
|
assert_eq!(db.load(1, &key, true), None);
|
||||||
for _ in 1..100 {
|
for _ in 1..100 {
|
||||||
let idx = thread_rng().gen_range(0, 99);
|
let idx = thread_rng().gen_range(0, 99);
|
||||||
assert_eq!(db.load(0, &pubkeys[idx], true), None);
|
let account0 = db.load(0, &pubkeys[idx], true).unwrap();
|
||||||
let account = db.load(1, &pubkeys[idx], true).unwrap();
|
let account1 = db.load(1, &pubkeys[idx], true).unwrap();
|
||||||
let mut default_account = Account::default();
|
let mut default_account = Account::default();
|
||||||
default_account.tokens = (idx + 1) as u64;
|
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);
|
cleanup_dirs(&paths);
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,8 @@ mod tests {
|
||||||
Blocktree::open(&ledger_path).expect("Expected to successfully open database ledger");
|
Blocktree::open(&ledger_path).expect("Expected to successfully open database ledger");
|
||||||
blocktree.write_entries(1, 0, 0, &entries).unwrap();
|
blocktree.write_entries(1, 0, 0, &entries).unwrap();
|
||||||
let entry_height = genesis_block.ticks_per_slot + entries.len() as u64;
|
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!(bank_forks_info.len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -746,7 +746,8 @@ mod tests {
|
||||||
|
|
||||||
// Close the validator so that rocksdb has locks available
|
// Close the validator so that rocksdb has locks available
|
||||||
validator_exit();
|
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 bank = bank_forks.working_bank();
|
||||||
let entry_height = bank_forks_info[0].entry_height;
|
let entry_height = bank_forks_info[0].entry_height;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue