test_verify_bank_capitalization works with write cache (#29107)
This commit is contained in:
parent
7ed22f7b18
commit
7180345ee1
|
@ -12948,58 +12948,64 @@ pub mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_verify_bank_capitalization() {
|
fn test_verify_bank_capitalization() {
|
||||||
use BankHashVerificationError::*;
|
for pass in 0..2 {
|
||||||
solana_logger::setup();
|
use BankHashVerificationError::*;
|
||||||
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
solana_logger::setup();
|
||||||
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
|
|
||||||
let key = solana_sdk::pubkey::new_rand();
|
let key = solana_sdk::pubkey::new_rand();
|
||||||
let some_data_len = 0;
|
let some_data_len = 0;
|
||||||
let some_slot: Slot = 0;
|
let some_slot: Slot = 0;
|
||||||
let account = AccountSharedData::new(1, some_data_len, &key);
|
let account = AccountSharedData::new(1, some_data_len, &key);
|
||||||
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.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);
|
db.add_root_and_flush_write_cache(some_slot);
|
||||||
assert_matches!(
|
db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);
|
||||||
db.verify_bank_hash_and_lamports(
|
assert_matches!(
|
||||||
|
db.verify_bank_hash_and_lamports(
|
||||||
|
some_slot,
|
||||||
|
&ancestors,
|
||||||
|
1,
|
||||||
|
true,
|
||||||
|
&EpochSchedule::default(),
|
||||||
|
&RentCollector::default(),
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
Ok(_)
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let native_account_pubkey = solana_sdk::pubkey::new_rand();
|
||||||
|
db.store_for_tests(
|
||||||
some_slot,
|
some_slot,
|
||||||
&ancestors,
|
&[(
|
||||||
1,
|
&native_account_pubkey,
|
||||||
true,
|
&solana_sdk::native_loader::create_loadable_account_for_test("foo"),
|
||||||
&EpochSchedule::default(),
|
)],
|
||||||
&RentCollector::default(),
|
);
|
||||||
false,
|
db.add_root_and_flush_write_cache(some_slot);
|
||||||
),
|
db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);
|
||||||
Ok(_)
|
assert_matches!(
|
||||||
);
|
db.verify_bank_hash_and_lamports(
|
||||||
|
some_slot,
|
||||||
|
&ancestors,
|
||||||
|
2,
|
||||||
|
true,
|
||||||
|
&EpochSchedule::default(),
|
||||||
|
&RentCollector::default(),
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
Ok(_)
|
||||||
|
);
|
||||||
|
|
||||||
let native_account_pubkey = solana_sdk::pubkey::new_rand();
|
assert_matches!(
|
||||||
db.store_for_tests(
|
db.verify_bank_hash_and_lamports(some_slot, &ancestors, 10, true, &EpochSchedule::default(), &RentCollector::default(), false,),
|
||||||
some_slot,
|
Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10
|
||||||
&[(
|
);
|
||||||
&native_account_pubkey,
|
}
|
||||||
&solana_sdk::native_loader::create_loadable_account_for_test("foo"),
|
|
||||||
)],
|
|
||||||
);
|
|
||||||
db.update_accounts_hash_for_tests(some_slot, &ancestors, true, true);
|
|
||||||
assert_matches!(
|
|
||||||
db.verify_bank_hash_and_lamports(
|
|
||||||
some_slot,
|
|
||||||
&ancestors,
|
|
||||||
2,
|
|
||||||
true,
|
|
||||||
&EpochSchedule::default(),
|
|
||||||
&RentCollector::default(),
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
Ok(_)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_matches!(
|
|
||||||
db.verify_bank_hash_and_lamports(some_slot, &ancestors, 10, true, &EpochSchedule::default(), &RentCollector::default(), false,),
|
|
||||||
Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue