Skip to content

Commit

Permalink
Remove extra sale period
Browse files Browse the repository at this point in the history
  • Loading branch information
seadanda committed Nov 15, 2024
1 parent ca6637b commit 3239d4b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions substrate/frame/broker/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,23 +840,19 @@ mod benches {
Ok(())
})?;

// Advance to the block before the rotate_sale in which the auto-renewals will take place.
advance_to::<T>(
timeslice_period.saturating_mul(config.region_length).saturating_mul(2) - 1,
);
// Advance to the block before `rotate_sale`.
advance_to::<T>(timeslice_period.saturating_mul(config.region_length) - 1);

// Advance one block and manually tick so we can isolate the `rotate_sale` call.
System::<T>::set_block_number(
timeslice_period.saturating_mul(config.region_length.saturating_mul(2)).into(),
);
System::<T>::set_block_number(timeslice_period.saturating_mul(config.region_length).into());
RCBlockNumberProviderOf::<T::Coretime>::set_block_number(
timeslice_period.saturating_mul(config.region_length.saturating_mul(2)).into(),
timeslice_period.saturating_mul(config.region_length).into(),
);
let mut status = Status::<T>::get().expect("Sale has started.");
let sale = SaleInfo::<T>::get().expect("Sale has started.");
Broker::<T>::process_core_count(&mut status);
Broker::<T>::process_revenue();
status.last_committed_timeslice = config.region_length.saturating_mul(2);
status.last_committed_timeslice = config.region_length;

#[block]
{
Expand All @@ -868,9 +864,9 @@ mod benches {
let new_sale = SaleInfo::<T>::get().expect("Sale has started.");
let now = RCBlockNumberProviderOf::<T::Coretime>::current_block_number();

assert_has_event::<T>(
assert_last_event::<T>(
Event::SaleInitialized {
sale_start: new_sale.region_end.into(),
sale_start: new_sale.region_begin.into(),
leadin_length: 1u32.into(),
start_price: Broker::<T>::sale_price(&new_sale, now),
end_price: new_prices.end_price,
Expand All @@ -896,7 +892,7 @@ mod benches {
who,
old_core: n_reservations as u16 + n_leases as u16 + indx as u16,
core: n_reservations as u16 + n_leases as u16 + indx as u16,
price: 11_000_000u32.into(), // Renewal bump from config.
price: 10_000_000u32.into(),
begin: new_sale.region_begin,
duration: config.region_length,
workload: Schedule::truncate_from(vec![ScheduleItem {
Expand Down

0 comments on commit 3239d4b

Please sign in to comment.