Uses AccountsBackgroundService::setup_bank_drop_callback() in tests (#31598)

This commit is contained in:
Brooks 2023-05-11 12:40:03 -04:00 committed by GitHub
parent a414b67b88
commit 93087324e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 8 deletions

View File

@ -123,7 +123,8 @@ impl TestEnvironment {
SocketAddrSpace::Unspecified,
));
let (pruned_banks_sender, pruned_banks_receiver) = crossbeam_channel::unbounded();
let pruned_banks_receiver =
AccountsBackgroundService::setup_bank_drop_callback(Arc::clone(&bank_forks));
let background_services = BackgroundServices::new(
Arc::clone(&exit),
Arc::clone(&cluster_info),
@ -132,12 +133,6 @@ impl TestEnvironment {
Arc::clone(&bank_forks),
);
let bank = bank_forks.read().unwrap().working_bank();
bank.set_callback(Some(Box::new(
bank.rc
.accounts
.accounts_db
.create_drop_bank_callback(pruned_banks_sender),
)));
assert!(bank
.feature_set
.is_active(&feature_set::epoch_accounts_hash::id()));
@ -159,7 +154,7 @@ impl TestEnvironment {
/// In order to shut down the background services correctly, each service's thread must be joined.
/// However, since `.join()` takes a `self` and `drop()` takes a `&mut self`, it means a "normal"
/// implementation of drop will no work. Instead, we must handle drop ourselves.
/// implementation of drop will not work. Instead, we must handle drop ourselves.
struct BackgroundServices {
exit: Arc<AtomicBool>,
accounts_background_service: ManuallyDrop<AccountsBackgroundService>,