common_runtime/weights/
pallet_session.rs1#![cfg_attr(rustfmt, rustfmt_skip)]
26#![allow(unused_parens)]
27#![allow(unused_imports)]
28#![allow(missing_docs)]
29
30use frame_support::{traits::Get, weights::Weight};
31use core::marker::PhantomData;
32
33pub struct SubstrateWeight<T>(PhantomData<T>);
35impl<T: frame_system::Config> pallet_session::WeightInfo for SubstrateWeight<T> {
36 fn set_keys() -> Weight {
41 Weight::from_parts(21_793_000, 4258)
46 .saturating_add(T::DbWeight::get().reads(2_u64))
47 .saturating_add(T::DbWeight::get().writes(2_u64))
48 }
49 fn purge_keys() -> Weight {
54 Weight::from_parts(16_311_000, 4240)
59 .saturating_add(T::DbWeight::get().reads(1_u64))
60 .saturating_add(T::DbWeight::get().writes(2_u64))
61 }
62}
63
64
65#[cfg(test)]
66mod tests {
67 use frame_support::{traits::Get, weights::Weight, dispatch::DispatchClass};
68 use crate::constants::{MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
69 use crate::weights::extrinsic_weights::ExtrinsicBaseWeight;
70
71 #[allow(dead_code)]
72 struct BlockWeights;
73 impl Get<frame_system::limits::BlockWeights> for BlockWeights {
74 fn get() -> frame_system::limits::BlockWeights {
75 frame_system::limits::BlockWeights::builder()
76 .base_block(Weight::zero())
77 .for_class(DispatchClass::all(), |weights| {
78 weights.base_extrinsic = ExtrinsicBaseWeight::get();
79 })
80 .for_class(DispatchClass::non_mandatory(), |weights| {
81 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
82 })
83 .build_or_panic()
84 }
85 }
86
87 #[test]
88 fn test_set_keys() {
89 assert!(
90 BlockWeights::get()
91 .per_class
92 .get(frame_support::dispatch::DispatchClass::Normal)
93 .max_extrinsic
94 .unwrap_or_else(<Weight as sp_runtime::traits::Bounded>::max_value)
95 .proof_size()
96 > 4258
97 );
98 }
99 #[test]
100 fn test_purge_keys() {
101 assert!(
102 BlockWeights::get()
103 .per_class
104 .get(frame_support::dispatch::DispatchClass::Normal)
105 .max_extrinsic
106 .unwrap_or_else(<Weight as sp_runtime::traits::Bounded>::max_value)
107 .proof_size()
108 > 4240
109 );
110 }
111}