Skip to content

Commit 30c1361

Browse files
fix : remove _{ } syntax from benchmark macro (#7822)
* commented use of common * hack to pass tests * another hack * remove all commented code * fix the easy tests * temp hack * follow through comma hack until better solution * patch macro * missed one * update benchmarks * update docs * fix docs * removed too much * fix changes Co-authored-by: Shawn Tabrizi <[email protected]>
1 parent d986887 commit 30c1361

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

src/benchmarking.rs

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,6 @@ fn create_identity_info<T: Config>(num_fields: u32) -> IdentityInfo {
107107
}
108108

109109
benchmarks! {
110-
// These are the common parameters along with their instancing.
111-
_ {
112-
let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;
113-
// extra parameter for the set_subs bench for previous sub accounts
114-
let p in 1 .. T::MaxSubAccounts::get() => ();
115-
let s in 1 .. T::MaxSubAccounts::get() => {
116-
// Give them s many sub accounts
117-
let caller: T::AccountId = whitelisted_caller();
118-
let _ = add_sub_accounts::<T>(&caller, s)?;
119-
};
120-
let x in 1 .. T::MaxAdditionalFields::get() => {
121-
// Create their main identity with x additional fields
122-
let info = create_identity_info::<T>(x);
123-
let caller: T::AccountId = whitelisted_caller();
124-
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller));
125-
Identity::<T>::set_identity(caller_origin, info)?;
126-
};
127-
}
128-
129110
add_registrar {
130111
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
131112
ensure!(Registrars::<T>::get().len() as u32 == r, "Registrars not set up correctly.");
@@ -135,10 +116,8 @@ benchmarks! {
135116
}
136117

137118
set_identity {
138-
let r in ...;
139-
// This X doesn't affect the caller ID up front like with the others, so we don't use the
140-
// standard preparation.
141-
let x in _ .. _ => ();
119+
let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;
120+
let x in 1 .. T::MaxAdditionalFields::get();
142121
let caller = {
143122
// The target user
144123
let caller: T::AccountId = whitelisted_caller();
@@ -204,9 +183,19 @@ benchmarks! {
204183
let caller_lookup = <T::Lookup as StaticLookup>::unlookup(caller.clone());
205184
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
206185

207-
let r in ...;
208-
let s in ...;
209-
let x in ...;
186+
let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;
187+
let s in 1 .. T::MaxSubAccounts::get() => {
188+
// Give them s many sub accounts
189+
let caller: T::AccountId = whitelisted_caller();
190+
let _ = add_sub_accounts::<T>(&caller, s)?;
191+
};
192+
let x in 1 .. T::MaxAdditionalFields::get() => {
193+
// Create their main identity with x additional fields
194+
let info = create_identity_info::<T>(x);
195+
let caller: T::AccountId = whitelisted_caller();
196+
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller));
197+
Identity::<T>::set_identity(caller_origin, info)?;
198+
};
210199

211200
// User requests judgement from all the registrars, and they approve
212201
for i in 0..r {
@@ -228,8 +217,14 @@ benchmarks! {
228217
let caller: T::AccountId = whitelisted_caller();
229218
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
230219

231-
let r in ...;
232-
let x in ...;
220+
let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;
221+
let x in 1 .. T::MaxAdditionalFields::get() => {
222+
// Create their main identity with x additional fields
223+
let info = create_identity_info::<T>(x);
224+
let caller: T::AccountId = whitelisted_caller();
225+
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller));
226+
Identity::<T>::set_identity(caller_origin, info)?;
227+
};
233228
}: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into())
234229
verify {
235230
assert_last_event::<T>(Event::<T>::JudgementRequested(caller, r-1).into());
@@ -240,8 +235,14 @@ benchmarks! {
240235
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller.clone()));
241236
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
242237

243-
let r in ...;
244-
let x in ...;
238+
let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;
239+
let x in 1 .. T::MaxAdditionalFields::get() => {
240+
// Create their main identity with x additional fields
241+
let info = create_identity_info::<T>(x);
242+
let caller: T::AccountId = whitelisted_caller();
243+
let caller_origin = <T as frame_system::Config>::Origin::from(RawOrigin::Signed(caller));
244+
Identity::<T>::set_identity(caller_origin, info)?;
245+
};
245246

246247
Identity::<T>::request_judgement(caller_origin, r - 1, 10u32.into())?;
247248
}: _(RawOrigin::Signed(caller.clone()), r - 1)
@@ -308,8 +309,7 @@ benchmarks! {
308309
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
309310

310311
let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::<T>(r)?;
311-
// For this x, it's the user identity that gts the fields, not the caller.
312-
let x in _ .. _ => {
312+
let x in 1 .. T::MaxAdditionalFields::get() => {
313313
let info = create_identity_info::<T>(x);
314314
Identity::<T>::set_identity(user_origin.clone(), info)?;
315315
};
@@ -322,10 +322,9 @@ benchmarks! {
322322
}
323323

324324
kill_identity {
325-
let r in ...;
326-
// Setting up our own account below.
327-
let s in _ .. _ => {};
328-
let x in _ .. _ => {};
325+
let r in 1 .. T::MaxRegistrars::get() => add_registrars::<T>(r)?;
326+
let s in 1 .. T::MaxSubAccounts::get();
327+
let x in 1 .. T::MaxAdditionalFields::get();
329328

330329
let target: T::AccountId = account("target", 0, SEED);
331330
let target_origin: <T as frame_system::Config>::Origin = RawOrigin::Signed(target.clone()).into();

0 commit comments

Comments
 (0)