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

[stable2407] Backport #7013 (#7015)


Backport #7013 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}
-->

---------

Co-authored-by: default avatarBastian Köcher <git@kchr.de>
Co-authored-by: default avatarEgorPopelyaev <egor@parity.io>
parent 826bb49d
Branches
No related merge requests found
title: 'pallet-bounties: Fix benchmarks for 0 ED'
doc:
- audience: Runtime Dev
description: 'Closes: https://github.com/paritytech/polkadot-sdk/issues/7009'
crates:
- name: pallet-bounties
bump: patch
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//! bounties pallet benchmarking. //! Bounties pallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
use super::*; use super::*;
...@@ -33,6 +31,16 @@ use pallet_treasury::Pallet as Treasury; ...@@ -33,6 +31,16 @@ use pallet_treasury::Pallet as Treasury;
const SEED: u32 = 0; const SEED: u32 = 0;
fn minimum_balance<T: Config<I>, I: 'static>() -> BalanceOf<T, I> {
let minimum_balance = T::Currency::minimum_balance();
if minimum_balance.is_zero() {
1u32.into()
} else {
minimum_balance
}
}
// Create bounties that are approved for use in `on_initialize`. // Create bounties that are approved for use in `on_initialize`.
fn create_approved_bounties<T: Config<I>, I: 'static>(n: u32) -> Result<(), BenchmarkError> { fn create_approved_bounties<T: Config<I>, I: 'static>(n: u32) -> Result<(), BenchmarkError> {
for i in 0..n { for i in 0..n {
...@@ -58,12 +66,10 @@ fn setup_bounty<T: Config<I>, I: 'static>( ...@@ -58,12 +66,10 @@ fn setup_bounty<T: Config<I>, I: 'static>(
let fee = value / 2u32.into(); let fee = value / 2u32.into();
let deposit = T::BountyDepositBase::get() + let deposit = T::BountyDepositBase::get() +
T::DataDepositPerByte::get() * T::MaximumReasonLength::get().into(); T::DataDepositPerByte::get() * T::MaximumReasonLength::get().into();
let _ = T::Currency::make_free_balance_be(&caller, deposit + T::Currency::minimum_balance()); let _ = T::Currency::make_free_balance_be(&caller, deposit + minimum_balance::<T, I>());
let curator = account("curator", u, SEED); let curator = account("curator", u, SEED);
let _ = T::Currency::make_free_balance_be( let _ =
&curator, T::Currency::make_free_balance_be(&curator, fee / 2u32.into() + minimum_balance::<T, I>());
fee / 2u32.into() + T::Currency::minimum_balance(),
);
let reason = vec![0; d as usize]; let reason = vec![0; d as usize];
(caller, curator, fee, value, reason) (caller, curator, fee, value, reason)
} }
...@@ -86,7 +92,7 @@ fn create_bounty<T: Config<I>, I: 'static>( ...@@ -86,7 +92,7 @@ fn create_bounty<T: Config<I>, I: 'static>(
fn setup_pot_account<T: Config<I>, I: 'static>() { fn setup_pot_account<T: Config<I>, I: 'static>() {
let pot_account = Bounties::<T, I>::account_id(); let pot_account = Bounties::<T, I>::account_id();
let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into()); let value = minimum_balance::<T, I>().saturating_mul(1_000_000_000u32.into());
let _ = T::Currency::make_free_balance_be(&pot_account, value); let _ = T::Currency::make_free_balance_be(&pot_account, value);
} }
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking; mod benchmarking;
pub mod migrations; pub mod migrations;
mod tests; mod tests;
......
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