update test for both feature gate status (#31708)
This commit is contained in:
parent
039991e780
commit
e84613b54c
|
@ -695,7 +695,7 @@ mod tests {
|
|||
solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry},
|
||||
solana_program_runtime::timings::ProgramTiming,
|
||||
solana_rpc::transaction_status_service::TransactionStatusService,
|
||||
solana_runtime::prioritization_fee_cache::PrioritizationFeeCache,
|
||||
solana_runtime::{cost_model::CostModel, prioritization_fee_cache::PrioritizationFeeCache},
|
||||
solana_sdk::{
|
||||
account::AccountSharedData,
|
||||
instruction::InstructionError,
|
||||
|
@ -1076,6 +1076,16 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_bank_process_and_record_transactions_cost_tracker() {
|
||||
for apply_cost_tracker_during_replay_enabled in [true, false] {
|
||||
bank_process_and_record_transactions_cost_tracker(
|
||||
apply_cost_tracker_during_replay_enabled,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn bank_process_and_record_transactions_cost_tracker(
|
||||
apply_cost_tracker_during_replay_enabled: bool,
|
||||
) {
|
||||
solana_logger::setup();
|
||||
let GenesisConfigInfo {
|
||||
genesis_config,
|
||||
|
@ -1083,7 +1093,9 @@ mod tests {
|
|||
..
|
||||
} = create_slow_genesis_config(10_000);
|
||||
let mut bank = Bank::new_no_wallclock_throttle_for_tests(&genesis_config);
|
||||
bank.deactivate_feature(&feature_set::apply_cost_tracker_during_replay::id());
|
||||
if !apply_cost_tracker_during_replay_enabled {
|
||||
bank.deactivate_feature(&feature_set::apply_cost_tracker_during_replay::id());
|
||||
}
|
||||
let bank = Arc::new(bank);
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
|
||||
|
@ -1150,10 +1162,13 @@ mod tests {
|
|||
|
||||
//
|
||||
// TEST: When a tx in a batch can't be executed (here because of account
|
||||
// locks), then its cost does not affect the cost tracker.
|
||||
// locks), then its cost does not affect the cost tracker only if qos
|
||||
// adjusts it with actual execution cost (when apply_cost_tracker_during_replay
|
||||
// is not enabled).
|
||||
//
|
||||
|
||||
let allocate_keypair = Keypair::new();
|
||||
|
||||
let transactions = sanitize_transactions(vec![
|
||||
system_transaction::transfer(&mint_keypair, &pubkey, 2, genesis_config.hash()),
|
||||
// intentionally use a tx that has a different cost
|
||||
|
@ -1164,6 +1179,13 @@ mod tests {
|
|||
1,
|
||||
),
|
||||
]);
|
||||
let mut expected_block_cost = 2 * single_transfer_cost;
|
||||
let mut expected_tracked_tx_count = 2;
|
||||
if apply_cost_tracker_during_replay_enabled {
|
||||
expected_block_cost +=
|
||||
CostModel::calculate_cost(&transactions[1], &bank.feature_set).sum();
|
||||
expected_tracked_tx_count += 1;
|
||||
}
|
||||
|
||||
let process_transactions_batch_output =
|
||||
consumer.process_and_record_transactions(&bank, &transactions, 0);
|
||||
|
@ -1178,8 +1200,8 @@ mod tests {
|
|||
assert!(commit_transactions_result.is_ok());
|
||||
assert_eq!(retryable_transaction_indexes, vec![1]);
|
||||
|
||||
assert_eq!(get_block_cost(), 2 * single_transfer_cost);
|
||||
assert_eq!(get_tx_count(), 2);
|
||||
assert_eq!(get_block_cost(), expected_block_cost);
|
||||
assert_eq!(get_tx_count(), expected_tracked_tx_count);
|
||||
|
||||
poh_recorder
|
||||
.read()
|
||||
|
|
Loading…
Reference in New Issue