mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 22:41:02 +00:00
Fix Benchmarks to enable batch run (#5523)
* some fixes * Update tips benchmark to be resiliant to genesis * Update Cargo.lock
This commit is contained in:
@@ -111,14 +111,15 @@ benchmarks! {
|
||||
second {
|
||||
let s in 0 .. MAX_SECONDERS;
|
||||
|
||||
let caller = funded_account::<T>("caller", 0);
|
||||
let proposal_hash = add_proposal::<T>(s)?;
|
||||
|
||||
// Create s existing "seconds"
|
||||
for i in 0 .. s {
|
||||
let seconder = funded_account::<T>("seconder", i);
|
||||
Democracy::<T>::second(RawOrigin::Signed(seconder).into(), 0)?;
|
||||
}
|
||||
|
||||
let caller = funded_account::<T>("caller", 0);
|
||||
let proposal_hash = add_proposal::<T>(s)?;
|
||||
}: _(RawOrigin::Signed(caller), 0)
|
||||
|
||||
vote {
|
||||
|
||||
@@ -219,11 +219,11 @@ benchmarks! {
|
||||
let c in 0 .. 1000;
|
||||
}: _(RawOrigin::Root, c)
|
||||
|
||||
force_no_eras { let i in 1 .. 1; }: _(RawOrigin::Root)
|
||||
force_no_eras { let i in 0 .. 1; }: _(RawOrigin::Root)
|
||||
|
||||
force_new_era {let i in 1 .. 1; }: _(RawOrigin::Root)
|
||||
force_new_era {let i in 0 .. 1; }: _(RawOrigin::Root)
|
||||
|
||||
force_new_era_always { let i in 1 .. 1; }: _(RawOrigin::Root)
|
||||
force_new_era_always { let i in 0 .. 1; }: _(RawOrigin::Root)
|
||||
|
||||
// Worst case scenario, the list of invulnerables is very long.
|
||||
set_invulnerables {
|
||||
|
||||
@@ -58,12 +58,15 @@ fn setup_awesome<T: Trait>(length: u32) -> (T::AccountId, Vec<u8>, T::AccountId)
|
||||
fn setup_tip<T: Trait>(r: u32, t: u32) ->
|
||||
Result<(T::AccountId, Vec<u8>, T::AccountId, BalanceOf<T>), &'static str>
|
||||
{
|
||||
let tippers_count = T::Tippers::count();
|
||||
|
||||
for i in 0 .. t {
|
||||
let member = account("member", i, SEED);
|
||||
T::Tippers::add(&member);
|
||||
ensure!(T::Tippers::contains(&member), "failed to add tipper");
|
||||
}
|
||||
|
||||
ensure!(T::Tippers::count() == t as usize, "problem creating tippers");
|
||||
ensure!(T::Tippers::count() == tippers_count + t as usize, "problem creating tippers");
|
||||
let caller = account("member", t - 1, SEED);
|
||||
let reason = vec![0; r as usize];
|
||||
let beneficiary = account("beneficiary", t, SEED);
|
||||
@@ -71,16 +74,19 @@ fn setup_tip<T: Trait>(r: u32, t: u32) ->
|
||||
Ok((caller, reason, beneficiary, value))
|
||||
}
|
||||
|
||||
// Create `t` new types for the tip proposal with `hash`.
|
||||
// This function automatically moves forward the block number to a time which
|
||||
// would resolve the tipping process.
|
||||
// Create `t` new tips for the tip proposal with `hash`.
|
||||
// This function automatically makes the tip able to close.
|
||||
fn create_tips<T: Trait>(t: u32, hash: T::Hash, value: BalanceOf<T>) -> Result<(), &'static str> {
|
||||
for i in 0 .. t {
|
||||
let caller = account("member", i, SEED);
|
||||
ensure!(T::Tippers::contains(&caller), "caller is not a tipper");
|
||||
Treasury::<T>::tip(RawOrigin::Signed(caller).into(), hash, value)?;
|
||||
}
|
||||
frame_system::Module::<T>::set_block_number(T::TipCountdown::get() * 10.into());
|
||||
Tips::<T>::mutate(hash, |maybe_tip| {
|
||||
if let Some(open_tip) = maybe_tip {
|
||||
open_tip.closes = Some(T::BlockNumber::zero());
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user