Skip to content

Commit

Permalink
Fix identity benchmark (paritytech#5229)
Browse files Browse the repository at this point in the history
* Set identity before calling set_subs.

* Remove -1.
  • Loading branch information
seerscode authored Mar 13, 2020
1 parent f5c6ebf commit 34a6d79
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions frame/identity/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ fn add_sub_accounts<T: Trait>(who: T::AccountId, s: u32) -> Result<Vec<(T::Accou
let sub_account = account::<T>("sub", i);
subs.push((sub_account, data.clone()));
}

// Set identity so `set_subs` does not fail.
let _ = T::Currency::make_free_balance_be(&who, BalanceOf::<T>::max_value());
let info = create_identity_info::<T>(1);
Identity::<T>::set_identity(who_origin.clone().into(), info)?;

Identity::<T>::set_subs(who_origin.into(), subs.clone())?;

return Ok(subs)
Expand Down Expand Up @@ -147,19 +153,8 @@ benchmarks! {

let caller = account::<T>("caller", 0);
let caller_origin: <T as frame_system::Trait>::Origin = RawOrigin::Signed(caller.clone()).into();
let _ = T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());

// Create their main identity
let info = create_identity_info::<T>(1);
Identity::<T>::set_identity(caller_origin, info)?;
}: _(RawOrigin::Signed(caller), {
let mut subs = Module::<T>::subs(&caller);
// Generic data to be used.
let data = Data::Raw(vec![0; 32]);
// Create an s+1 sub account to add
subs.push((account::<T>("sub", s + 1), data));
subs
})
let subs = Module::<T>::subs(&caller);
}: _(RawOrigin::Signed(caller), subs)

clear_identity {
let caller = account::<T>("caller", 0);
Expand Down

0 comments on commit 34a6d79

Please sign in to comment.