Companion for paritytech/substrate#12868 (#6406)

* Replace WEIGHT_PER_* with WEIGHT_REF_TIME_PER_*

* cargo fmt

* Update substrate
This commit is contained in:
Keith Yeung
2022-12-09 01:56:37 +09:00
committed by GitHub
parent e17130cd13
commit 6f666a07b4
28 changed files with 312 additions and 298 deletions
@@ -35,7 +35,7 @@
// --header=./file_header.txt
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_PER_NANOS, Weight};
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Time to execute a NO-OP extrinsic, for example `System::remark`.
@@ -51,7 +51,8 @@ parameter_types! {
/// 99th: 96_279
/// 95th: 95_584
/// 75th: 95_005
pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(94_889);
pub const ExtrinsicBaseWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(94_889));
}
#[cfg(test)]
@@ -67,12 +68,12 @@ mod test_weights {
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}