Skip to content

Commit

Permalink
Fix on_init bench
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Sep 13, 2024
1 parent 6d28fc9 commit 44fbb39
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions substrate/frame/treasury/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ fn setup_proposal<T: Config<I>, I: 'static>(

// Create proposals that are approved for use in `on_initialize`.
fn create_approved_proposals<T: Config<I>, I: 'static>(n: u32) -> Result<(), &'static str> {
let origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let spender = T::SpendOrigin::try_successful_origin();

for i in 0..n {
let (_, value, lookup) = setup_proposal::<T, I>(i);
Treasury::<T, I>::spend_local(origin.clone(), value, lookup)?;

if let Ok(origin) = &spender {
Treasury::<T, I>::spend_local(origin.clone(), value, lookup)?;
}
}

if spender.is_ok() {
ensure!(Approvals::<T, I>::get().len() == n as usize, "Not all approved");
}
ensure!(Approvals::<T, I>::get().len() == n as usize, "Not all approved");
Ok(())
}

Expand Down

0 comments on commit 44fbb39

Please sign in to comment.