From 210773efc07e741bdab9d46d6cde78c8fe03d35e Mon Sep 17 00:00:00 2001 From: Ignazio Bovo Date: Tue, 2 Apr 2024 17:48:12 +0200 Subject: [PATCH] fix: :green_heart: round of ci fixes --- package.json | 1 + runtime-modules/working-group/src/benchmarking.rs | 15 +++++++++------ runtime/src/lib.rs | 7 ------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 130c686fcd..101f8f14f5 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "start": "./start.sh", "test": "./tests/network-tests/run-tests.sh", "cargo-checks": "./scripts/cargo-checks.sh", + "cargo-checks-with-benchmarking": "./scripts/cargo-checks-with-benchmarking.sh", "cargo-build": "./scripts/cargo-build.sh", "lint": "./scripts/lint-typescript.sh", "update-chain-metadata": "./scripts/fetch-chain-metadata.sh | tee chain-metadata.json query-node/chain-metadata/$(./scripts/fetch-chain-spec-version.sh).json >/dev/null", diff --git a/runtime-modules/working-group/src/benchmarking.rs b/runtime-modules/working-group/src/benchmarking.rs index a3d431e506..15ab88ba0a 100644 --- a/runtime-modules/working-group/src/benchmarking.rs +++ b/runtime-modules/working-group/src/benchmarking.rs @@ -14,6 +14,7 @@ use crate::types::StakeParameters; use crate::Module as WorkingGroup; use balances::Pallet as Balances; use membership::Module as Membership; +use vesting::Config as VestingConfig; const SEED: u32 = 0; const MAX_KILOBYTES_METADATA: u32 = 100; @@ -255,7 +256,7 @@ pub fn complete_opening + membership::Config, I: Instance>( benchmarks_instance! { where_clause { - where T: membership::Config + where T: membership::Config + Config } on_initialize_leaving { @@ -796,21 +797,23 @@ benchmarks_instance! { } vested_spend_from_budget { + use core::ops::Div; + let (lead_id, _) = insert_a_worker::( OpeningType::Leader, 0, None ); - let raw_amount_vesting = 10_000u32; - let amount_vesting = VestingBalanceOf::::from(raw_amount_vesting); - let budget = BalanceOf::::from(raw_amount_vesting * 10); + let amount = core::cmp::max(::MinVestedTransfer::get(), VestingBalanceOf::::from(10_000u32)); + let amount_balance = >::VestingBalanceToBalance::convert(amount); + let budget = amount_balance.saturating_mul(10u32.into()); let current_block = ::BlockNumber::from(1u32); - let vested = VestingInfoOf::::new(amount_vesting, amount_vesting, current_block); + let vested = VestingInfoOf::::new(amount, amount.div(10u32.into()), current_block); WorkingGroup::::set_budget(RawOrigin::Root.into(), budget).unwrap(); }: _ (RawOrigin::Signed(lead_id.clone()), lead_id.clone(), vested, None) verify { - assert_eq!(WorkingGroup::::budget(), BalanceOf::::from(90_000u32), "Budget not updated"); + assert_eq!(WorkingGroup::::budget(), budget.saturating_sub(amount_balance), "Budget not updated"); assert_last_event::(RawEvent::VestedBudgetSpending(lead_id, vested, None).into()); } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index d4df93fb1d..9ea80b2b92 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1780,18 +1780,11 @@ impl bounty::Config for Runtime { type CreatorStateBloatBondAmount = CreatorStateBloatBondAmount; } -#[cfg(not(feature = "runtime-benchmarks"))] parameter_types! { pub const MinVestedTransfer: Balance = dollars!(1); pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::empty(); } -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub MinVestedTransfer: Balance = ExistentialDeposit::get(); - pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::empty(); -} - impl pallet_vesting::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances;