Introduce frozen indices. (#6307)

* Introduce frozen indices.

* Fix.

* Bump runtime

* Benchmark for freeze

* Fix

* fix benchmarks

* update freeze weights

* remove copy pasta

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2020-06-09 16:31:18 +02:00
committed by GitHub
parent 07b984b609
commit d29baf9945
4 changed files with 94 additions and 15 deletions
+16 -1
View File
@@ -83,11 +83,25 @@ benchmarks! {
T::Currency::make_free_balance_be(&recipient, BalanceOf::<T>::max_value());
// Claim the index
Indices::<T>::claim(RawOrigin::Signed(original).into(), account_index)?;
}: _(RawOrigin::Root, recipient.clone(), account_index)
}: _(RawOrigin::Root, recipient.clone(), account_index, false)
verify {
assert_eq!(Accounts::<T>::get(account_index).unwrap().0, recipient);
}
freeze {
// Index being claimed
let i in 0 .. 1000;
let account_index = T::AccountIndex::from(i);
// Setup accounts
let caller: T::AccountId = account("caller", 0, SEED);
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
// Claim the index
Indices::<T>::claim(RawOrigin::Signed(caller.clone()).into(), account_index)?;
}: _(RawOrigin::Signed(caller.clone()), account_index)
verify {
assert_eq!(Accounts::<T>::get(account_index).unwrap().2, true);
}
// TODO in another PR: lookup and unlookup trait weights (not critical)
}
@@ -104,6 +118,7 @@ mod tests {
assert_ok!(test_benchmark_transfer::<Test>());
assert_ok!(test_benchmark_free::<Test>());
assert_ok!(test_benchmark_force_transfer::<Test>());
assert_ok!(test_benchmark_freeze::<Test>());
});
}
}