Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions accounts-db/src/accounts_db/geyser_plugin_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,19 @@ impl AccountsDb {
pub mod tests {
use {
super::*,
crate::accounts_update_notifier_interface::{
AccountForGeyser, AccountsUpdateNotifier, AccountsUpdateNotifierInterface,
crate::{
accounts_db::{AccountsDbConfig, MarkObsoleteAccounts, ACCOUNTS_DB_CONFIG_FOR_TESTING},
accounts_update_notifier_interface::{
AccountForGeyser, AccountsUpdateNotifier, AccountsUpdateNotifierInterface,
},
},
dashmap::DashMap,
solana_account::ReadableAccount as _,
std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
test_case::test_case,
};

impl AccountsDb {
Expand Down Expand Up @@ -202,9 +206,18 @@ pub mod tests {
}
}

#[test]
fn test_notify_account_restore_from_snapshot() {
let mut accounts = AccountsDb::new_single_for_tests();
#[test_case(MarkObsoleteAccounts::Enabled)]
#[test_case(MarkObsoleteAccounts::Disabled)]
fn test_notify_account_restore_from_snapshot(mark_obsolete_accounts: MarkObsoleteAccounts) {
let mut accounts = AccountsDb::new_with_config(
Vec::new(),
Some(AccountsDbConfig {
mark_obsolete_accounts,
..ACCOUNTS_DB_CONFIG_FOR_TESTING
}),
None,
Arc::default(),
);
let key1 = Pubkey::new_unique();
let key2 = Pubkey::new_unique();
let account = AccountSharedData::new(1, 0, &Pubkey::default());
Expand All @@ -214,13 +227,16 @@ pub mod tests {
// to correct slots. Cache flush can skip writes if accounts have already been written to
// a newer slot
accounts.store_for_tests((0, [(&key1, &account)].as_slice()));
accounts.add_root_and_flush_write_cache(0);
accounts.add_root(0);
accounts.flush_slot_cache(0);
accounts.store_for_tests((1, [(&key1, &account)].as_slice()));
accounts.add_root_and_flush_write_cache(1);
accounts.add_root(1);
accounts.flush_slot_cache(1);

// Account with key2 is updated in a single slot, should get notified once
accounts.store_for_tests((2, [(&key2, &account)].as_slice()));
accounts.add_root_and_flush_write_cache(2);
accounts.add_root(2);
accounts.flush_slot_cache(2);

// Do the notification
let notifier = GeyserTestPlugin::default();
Expand Down
Loading