Skip to content

Commit

Permalink
Fix Tests (#281)
Browse files Browse the repository at this point in the history
* fix tests
  • Loading branch information
jedleggett authored Mar 21, 2023
1 parent 3fa9d50 commit eb4a34b
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions core/src/bundle_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ impl BundleStage {
) {
const LOOP_STATS_METRICS_PERIOD: Duration = Duration::from_secs(1);

let ticks_per_slot = poh_recorder.read().unwrap().ticks_per_slot();
let recorder = poh_recorder.read().unwrap().recorder();
let qos_service = QosService::new(cost_model, id);

Expand All @@ -1520,19 +1521,11 @@ impl BundleStage {
current_bundle_block_limit: MAX_BLOCK_UNITS,
current_tx_block_limit: MAX_BLOCK_UNITS.saturating_sub(preallocated_bundle_cost),
initial_allocated_cost: preallocated_bundle_cost,
unreserved_ticks: poh_recorder
.write()
.unwrap()
.ticks_per_slot()
.saturating_div(5),
unreserved_ticks: ticks_per_slot.saturating_div(5), // 20% for non-bundles
};
debug!(
"initialize bundled reserved space: {preallocated_bundle_cost} cu for {} ticks",
poh_recorder
.write()
.unwrap()
.ticks_per_slot()
.saturating_sub(reserved_space.unreserved_ticks)
ticks_per_slot.saturating_sub(reserved_space.unreserved_ticks)
);

while !exit.load(Ordering::Relaxed) {
Expand Down Expand Up @@ -1744,6 +1737,8 @@ mod tests {
{
bank.write_cost_tracker().unwrap().set_limits(1, 1, 1);
}
let current_block_cost_limit = bank.read_cost_tracker().unwrap().block_cost_limit();
debug!("current block cost limit: {current_block_cost_limit}");
let blockstore = Arc::new(
Blockstore::open(ledger_path.path())
.expect("Expected to be able to open database ledger"),
Expand All @@ -1756,6 +1751,7 @@ mod tests {
};
let (exit, poh_recorder, poh_service, _entry_receiver) =
create_test_recorder(&bank, &blockstore, Some(poh_config), None);
let ticks_per_slot = poh_recorder.read().unwrap().ticks_per_slot();
let recorder = poh_recorder.read().unwrap().recorder();
let cost_model = Arc::new(RwLock::new(CostModel::default()));
let qos_service = QosService::new(cost_model, 0);
Expand All @@ -1780,10 +1776,10 @@ mod tests {
&mut bundle_stage_leader_stats,
&TEST_MAX_RETRY_DURATION,
&mut BundleReservedSpace {
current_tx_block_limit: 1,
current_bundle_block_limit: 1,
current_tx_block_limit: current_block_cost_limit,
current_bundle_block_limit: current_block_cost_limit,
initial_allocated_cost: 0,
unreserved_ticks: poh_recorder.read().unwrap().ticks_per_slot(),
unreserved_ticks: ticks_per_slot,
},
);

Expand Down Expand Up @@ -2048,7 +2044,8 @@ mod tests {
bank.write_cost_tracker()
.unwrap()
.set_limits(u64::MAX, u64::MAX, u64::MAX);

let current_block_cost_limit = bank.read_cost_tracker().unwrap().block_cost_limit();
debug!("current block cost limit: {current_block_cost_limit}");
let ledger_path = get_tmp_ledger_path_auto_delete!();
let blockstore = Arc::new(
Blockstore::open(ledger_path.path())
Expand All @@ -2062,6 +2059,7 @@ mod tests {
};
let (exit, poh_recorder, poh_service, _entry_receiver) =
create_test_recorder(&bank, &blockstore, Some(poh_config), None);
let ticks_per_slot = poh_recorder.read().unwrap().ticks_per_slot();
let recorder = poh_recorder.read().unwrap().recorder();
let (gossip_vote_sender, _gossip_vote_receiver) = unbounded();
let cost_model = Arc::new(RwLock::new(CostModel::default()));
Expand Down Expand Up @@ -2117,10 +2115,10 @@ mod tests {
&mut bundle_stage_leader_stats,
&TEST_MAX_RETRY_DURATION,
&mut BundleReservedSpace {
current_tx_block_limit: u64::MAX,
current_bundle_block_limit: u64::MAX,
current_tx_block_limit: current_block_cost_limit,
current_bundle_block_limit: current_block_cost_limit,
initial_allocated_cost: 0,
unreserved_ticks: poh_recorder.read().unwrap().ticks_per_slot(),
unreserved_ticks: ticks_per_slot,
},
);
info!("test_bundle_max_retries result: {:?}", result);
Expand Down

0 comments on commit eb4a34b

Please sign in to comment.