mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 04:31:02 +00:00
Benchmark macro (#4962)
* MAcro benchamrks * Iterative macro * Tidying it up. * Macro improvements * Bits.. * Last benchmaks. * Repo benchmark macro * Add the possibility of evaluating arbitrary expressions in a benchmaark * Better syntax and docs * Update `BenchmarkParameter` * Add `ignore` to sudo-code in docs * First try of timestamp implementation. * Fix macro docs, remove warnings. * Use macro in balances pallet. * Make some space in frame benchmarking. * Remove _benchmarks_seed variable. * Bump impl_version. Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Marcio Diaz <marcio@parity.io>
This commit is contained in:
@@ -394,7 +394,7 @@ decl_storage! {
|
||||
/// Alternative "sub" identities of this account.
|
||||
///
|
||||
/// The first item is the deposit, the second is a vector of the accounts.
|
||||
pub SubsOf get(fn subs):
|
||||
pub SubsOf get(fn subs_of):
|
||||
map hasher(blake2_256) T::AccountId => (BalanceOf<T>, Vec<T::AccountId>);
|
||||
|
||||
/// The set of registrars. Not expected to get very big as can only be added through a
|
||||
@@ -875,6 +875,16 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
/// Get the subs of an account.
|
||||
pub fn subs(who: &T::AccountId) -> Vec<(T::AccountId, Data)> {
|
||||
SubsOf::<T>::get(who).1
|
||||
.into_iter()
|
||||
.filter_map(|a| SuperOf::<T>::get(&a).map(|x| (a, x.1)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1097,14 +1107,14 @@ mod tests {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), ten()));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert_eq!(Identity::subs(10), (10, vec![20]));
|
||||
assert_eq!(Identity::subs_of(10), (10, vec![20]));
|
||||
assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1]))));
|
||||
|
||||
// push another item and re-set it.
|
||||
subs.push((30, Data::Raw(vec![50; 1])));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 70);
|
||||
assert_eq!(Identity::subs(10), (20, vec![20, 30]));
|
||||
assert_eq!(Identity::subs_of(10), (20, vec![20, 30]));
|
||||
assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1]))));
|
||||
assert_eq!(Identity::super_of(30), Some((10, Data::Raw(vec![50; 1]))));
|
||||
|
||||
@@ -1112,7 +1122,7 @@ mod tests {
|
||||
subs[0] = (40, Data::Raw(vec![60; 1]));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone()));
|
||||
assert_eq!(Balances::free_balance(10), 70); // no change in the balance
|
||||
assert_eq!(Identity::subs(10), (20, vec![40, 30]));
|
||||
assert_eq!(Identity::subs_of(10), (20, vec![40, 30]));
|
||||
assert_eq!(Identity::super_of(20), None);
|
||||
assert_eq!(Identity::super_of(30), Some((10, Data::Raw(vec![50; 1]))));
|
||||
assert_eq!(Identity::super_of(40), Some((10, Data::Raw(vec![60; 1]))));
|
||||
@@ -1120,7 +1130,7 @@ mod tests {
|
||||
// clear
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), vec![]));
|
||||
assert_eq!(Balances::free_balance(10), 90);
|
||||
assert_eq!(Identity::subs(10), (0, vec![]));
|
||||
assert_eq!(Identity::subs_of(10), (0, vec![]));
|
||||
assert_eq!(Identity::super_of(30), None);
|
||||
assert_eq!(Identity::super_of(40), None);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user