pallet-lottery: add generate_storage_info (#10594)

* pallet-lottery: add generate_storage_info

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-lottery: test call_to_indices with TooManyCalls

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* review: move try_push above transfer

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-lottery: test stop_repeat

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-lottery: test do_buy_ticket as white-box

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-lottery: use BoundedVec in bechmarks

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-lottery: fix zero div panic

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* review: extend buy_ticket tests

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* review: test buy_ticket AlreadyParticipating

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* review: use /// comments on private functions

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* review: use with_bounded_capacity

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-01-11 15:22:27 +01:00
committed by GitHub
parent 5e4035dcaa
commit b630f1b0e6
3 changed files with 235 additions and 32 deletions
+7 -4
View File
@@ -22,7 +22,10 @@
use super::*;
use frame_benchmarking::{account, benchmarks, whitelisted_caller};
use frame_support::traits::{EnsureOrigin, OnInitialize};
use frame_support::{
storage::bounded_vec::BoundedVec,
traits::{EnsureOrigin, OnInitialize},
};
use frame_system::RawOrigin;
use sp_runtime::traits::{Bounded, Zero};
@@ -55,12 +58,12 @@ benchmarks! {
let set_code_index: CallIndex = Lottery::<T>::call_to_index(
&frame_system::Call::<T>::set_code{ code: vec![] }.into()
)?;
let already_called: (u32, Vec<CallIndex>) = (
let already_called: (u32, BoundedVec<CallIndex, T::MaxCalls>) = (
LotteryIndex::<T>::get(),
vec![
BoundedVec::<CallIndex, T::MaxCalls>::try_from(vec![
set_code_index;
T::MaxCalls::get().saturating_sub(1) as usize
],
]).unwrap(),
);
Participants::<T>::insert(&caller, already_called);