referrerpolicy=no-referrer-when-downgrade

parachain_template_runtime/weights/
block_weights.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18pub mod constants {
19	use polkadot_sdk::*;
20
21	use frame_support::{
22		parameter_types,
23		weights::{constants, Weight},
24	};
25
26	parameter_types! {
27		/// Importing a block with 0 Extrinsics.
28		pub const BlockExecutionWeight: Weight =
29			Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000), 0);
30	}
31
32	#[cfg(test)]
33	mod test_weights {
34		use polkadot_sdk::*;
35
36		use frame_support::weights::constants;
37
38		/// Checks that the weight exists and is sane.
39		// NOTE: If this test fails but you are sure that the generated values are fine,
40		// you can delete it.
41		#[test]
42		fn sane() {
43			let w = super::constants::BlockExecutionWeight::get();
44
45			// At least 100 µs.
46			assert!(
47				w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
48				"Weight should be at least 100 µs."
49			);
50			// At most 50 ms.
51			assert!(
52				w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
53				"Weight should be at most 50 ms."
54			);
55		}
56	}
57}