Skip to content
Snippets Groups Projects
Unverified Commit 240e20b9 authored by paritytech-cmd-bot-polkadot-sdk[bot]'s avatar paritytech-cmd-bot-polkadot-sdk[bot] Committed by GitHub
Browse files

[stable2407] Backport #5713 (#5739)


Backport #5713 into `stable2407` from bkchr.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: default avatarBastian Köcher <git@kchr.de>
Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
parent 51a1705d
Branches
No related merge requests found
title: "pallet-treasury: Improve `remove_approval` benchmark"
doc:
- audience: Runtime Dev
description: |
Fix the `remove_approval` benchmark when `SpendOrigin` doesn't return any `succesful_origin`.
crates:
- name: pallet-treasury
bump: patch
......@@ -26,7 +26,7 @@ use frame_benchmarking::{
v2::*,
};
use frame_support::{
ensure,
assert_err, assert_ok, ensure,
traits::{
tokens::{ConversionFromAssetBalance, PaymentStatus},
EnsureOrigin, OnInitialize,
......@@ -126,16 +126,31 @@ mod benchmarks {
#[benchmark]
fn remove_approval() -> Result<(), BenchmarkError> {
let origin =
T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let (_, value, beneficiary_lookup) = setup_proposal::<T, _>(SEED);
Treasury::<T, _>::spend_local(origin, value, beneficiary_lookup)?;
let proposal_id = Treasury::<T, _>::proposal_count() - 1;
let (spend_exists, proposal_id) =
if let Ok(origin) = T::SpendOrigin::try_successful_origin() {
let (_, value, beneficiary_lookup) = setup_proposal::<T, _>(SEED);
Treasury::<T, _>::spend_local(origin, value, beneficiary_lookup)?;
let proposal_id = Treasury::<T, _>::proposal_count() - 1;
(true, proposal_id)
} else {
(false, 0)
};
let reject_origin =
T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
#[extrinsic_call]
_(reject_origin as T::RuntimeOrigin, proposal_id);
#[block]
{
let res =
Treasury::<T, _>::remove_approval(reject_origin as T::RuntimeOrigin, proposal_id);
if spend_exists {
assert_ok!(res);
} else {
assert_err!(res, Error::<T, _>::ProposalNotApproved);
}
}
Ok(())
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment