test_verify_bank_capitalization works with write cache (#29107)

This commit is contained in:
Jeff Washington (jwash) 2022-12-06 12:24:43 -06:00 committed by GitHub
parent 7ed22f7b18
commit 7180345ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 48 deletions

View File

@ -12948,6 +12948,7 @@ pub mod tests {
#[test] #[test]
fn test_verify_bank_capitalization() { fn test_verify_bank_capitalization() {
for pass in 0..2 {
use BankHashVerificationError::*; use BankHashVerificationError::*;
solana_logger::setup(); solana_logger::setup();
let db = AccountsDb::new(Vec::new(), &ClusterType::Development); let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
@ -12959,7 +12960,8 @@ pub mod tests {
let ancestors = vec![(some_slot, 0)].into_iter().collect(); let ancestors = vec![(some_slot, 0)].into_iter().collect();
db.store_for_tests(some_slot, &[(&key, &account)]); db.store_for_tests(some_slot, &[(&key, &account)]);
db.add_root(some_slot); if pass == 0 {
db.add_root_and_flush_write_cache(some_slot);
db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true); db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);
assert_matches!( assert_matches!(
db.verify_bank_hash_and_lamports( db.verify_bank_hash_and_lamports(
@ -12973,6 +12975,8 @@ pub mod tests {
), ),
Ok(_) Ok(_)
); );
continue;
}
let native_account_pubkey = solana_sdk::pubkey::new_rand(); let native_account_pubkey = solana_sdk::pubkey::new_rand();
db.store_for_tests( db.store_for_tests(
@ -12982,6 +12986,7 @@ pub mod tests {
&solana_sdk::native_loader::create_loadable_account_for_test("foo"), &solana_sdk::native_loader::create_loadable_account_for_test("foo"),
)], )],
); );
db.add_root_and_flush_write_cache(some_slot);
db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true); db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);
assert_matches!( assert_matches!(
db.verify_bank_hash_and_lamports( db.verify_bank_hash_and_lamports(
@ -13001,6 +13006,7 @@ pub mod tests {
Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10 Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10
); );
} }
}
#[test] #[test]
fn test_verify_bank_hash_no_account() { fn test_verify_bank_hash_no_account() {