Skip to content

Commit

Permalink
Merge pull request #564 from freeverseio/fix/blockweight
Browse files Browse the repository at this point in the history
Add Comprehensive Unit Tests for BlockWeights Configuration
  • Loading branch information
asiniscalchi authored Apr 15, 2024
2 parents 56bfaf0 + 96ac67b commit 9ef7316
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,35 @@ frame_support::parameter_types! {
pub BlockWeights: limits::BlockWeights =
limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
}

#[cfg(test)]
mod tests {
use super::*;
use frame_support::dispatch::DispatchClass;

#[test]
fn test_block_weights() {
let weights = BlockWeights::get();

assert_eq!(weights.base_block, Weight::from_parts(390584000, 0));
assert_eq!(weights.max_block, Weight::from_parts(500000000000, 5242880));

let normal = weights.per_class.get(DispatchClass::Normal);
assert_eq!(normal.base_extrinsic, Weight::from_parts(124414000, 0));
assert_eq!(normal.max_extrinsic, Some(Weight::from_parts(324875586000, 3407872)));
assert_eq!(normal.max_total, Some(Weight::from_parts(375000000000, 3932160)));
assert_eq!(normal.reserved, Some(Weight::from_parts(0, 0)));

let mandatory = weights.per_class.get(DispatchClass::Mandatory);
assert_eq!(mandatory.base_extrinsic, Weight::from_parts(124414000, 0));
assert_eq!(mandatory.max_extrinsic, None);
assert_eq!(mandatory.max_total, None);
assert_eq!(mandatory.reserved, None);

let operational = weights.per_class.get(DispatchClass::Operational);
assert_eq!(operational.base_extrinsic, Weight::from_parts(124414000, 0));
assert_eq!(operational.max_extrinsic, Some(Weight::from_parts(449875586000, 4718592)));
assert_eq!(operational.max_total, Some(Weight::from_parts(500000000000, 5242880)));
assert_eq!(operational.reserved, Some(Weight::from_parts(125000000000, 1310720)));
}
}

0 comments on commit 9ef7316

Please sign in to comment.