Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Apr 2, 2024
1 parent 7b4d0c8 commit 37ff3c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
14 changes: 5 additions & 9 deletions substrate/frame/benchmarking/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,6 @@ macro_rules! impl_benchmark {
// Always reset the state after the benchmark.
$crate::__private::defer!($crate::benchmarking::wipe_db());

// Set the block number to at least 1 so events are deposited.
if $crate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Pallet::<T>::set_block_number(1u32.into());
}

$crate::__private::log::trace!(
target: "benchmark",
Expand All @@ -1095,6 +1091,11 @@ macro_rules! impl_benchmark {
// benchmark.
let whitelist = whitelist.clone();
let mut recording = $crate::BenchmarkRecording::new($crate::__private::Box::new(move || {
// Set the block number to at least 1 so events are deposited.
if $crate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Pallet::<T>::set_block_number(1u32.into());
}

// Commit the externalities to the database, flushing the DB cache.
// This will enable worst case scenario for reading from the database.
$crate::benchmarking::commit_db();
Expand Down Expand Up @@ -1222,11 +1223,6 @@ macro_rules! impl_benchmark_test {
// Always reset the state after the benchmark.
$crate::__private::defer!($crate::benchmarking::wipe_db());

// Set the block number to at least 1 so events are deposited.
if $crate::__private::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Pallet::<T>::set_block_number(1u32.into());
}

// Run execution + verification
<SelectedBenchmark as $crate::BenchmarkingSetup<T, _>>::test_instance(&selected_benchmark, &c)
};
Expand Down
17 changes: 5 additions & 12 deletions substrate/frame/support/procedural/src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,6 @@ pub fn benchmarks(
#krate::__private::defer!(#krate::benchmarking::wipe_db());

// Set the block number to at least 1 so events are deposited.
if #krate::__private::Zero::is_zero(&#frame_system::Pallet::<T>::block_number()) {
#frame_system::Pallet::<T>::set_block_number(1u32.into());
}

#krate::__private::log::trace!(
target: "benchmark",
"Start Benchmark: {} ({:?})",
Expand All @@ -752,6 +748,10 @@ pub fn benchmarks(

let whitelist = whitelist.clone();
let mut recording = #krate::BenchmarkRecording::new(#krate::__private::Box::new(move || {
if #krate::__private::Zero::is_zero(&#frame_system::Pallet::<T>::block_number()) {
#frame_system::Pallet::<T>::set_block_number(1u32.into());
}

// Commit the externalities to the database, flushing the DB cache.
// This will enable worst case scenario for reading from the database.
#krate::benchmarking::commit_db();
Expand Down Expand Up @@ -1113,14 +1113,7 @@ fn expand_benchmark(
| -> Result<(), #krate::BenchmarkError> {
// Always reset the state after the benchmark.
#krate::__private::defer!(#krate::benchmarking::wipe_db());

// Set the block number to at least 1 so events are deposited.
if #krate::__private::Zero::is_zero(&#frame_system::Pallet::<T>::block_number()) {
#frame_system::Pallet::<T>::set_block_number(1u32.into());
}

// Run execution + verification
< SelectedBenchmark as #krate::BenchmarkingSetup<T, _> >::test_instance(&selected_benchmark, &c)
<SelectedBenchmark as #krate::BenchmarkingSetup<T, _>>::test_instance(&selected_benchmark, &c)
};

if components.is_empty() {
Expand Down

0 comments on commit 37ff3c0

Please sign in to comment.