Skip to content

Commit

Permalink
ensure on_initialize_with_bump_era under block weight limit (#2816)
Browse files Browse the repository at this point in the history
* add test for on_initialize_with_bump_era to ensure the weight within block weight limit

* reduce ProcessRedeemRequestsLimit
  • Loading branch information
xlc authored Oct 14, 2024
1 parent fa648e1 commit d9652d6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["resolver"]

[workspace]
members = [
"modules/*",
Expand Down
12 changes: 11 additions & 1 deletion runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ impl module_homa::Config for Runtime {
type XcmInterface = XcmInterface;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
type NominationsProvider = NomineesElection;
type ProcessRedeemRequestsLimit = ConstU32<2_000>;
type ProcessRedeemRequestsLimit = ConstU32<1_000>;
}

parameter_types! {
Expand Down Expand Up @@ -2719,4 +2719,14 @@ mod tests {
If the limit is too strong, maybe consider increasing the limit",
);
}

#[test]
fn check_on_initialize_with_bump_era_weight() {
use module_homa::WeightInfo;
let weight = weights::module_homa::WeightInfo::<Runtime>::on_initialize_with_bump_era(
<Runtime as module_homa::Config>::ProcessRedeemRequestsLimit::get(),
);
let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2);
assert!(weight.all_lt(block_weight));
}
}
12 changes: 11 additions & 1 deletion runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ impl module_homa::Config for Runtime {
type XcmInterface = XcmInterface;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
type NominationsProvider = NomineesElection;
type ProcessRedeemRequestsLimit = ConstU32<2_000>;
type ProcessRedeemRequestsLimit = ConstU32<1_000>;
}

parameter_types! {
Expand Down Expand Up @@ -2752,4 +2752,14 @@ mod tests {
If the limit is too strong, maybe consider increasing the limit",
);
}

#[test]
fn check_on_initialize_with_bump_era_weight() {
use module_homa::WeightInfo;
let weight = weights::module_homa::WeightInfo::<Runtime>::on_initialize_with_bump_era(
<Runtime as module_homa::Config>::ProcessRedeemRequestsLimit::get(),
);
let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2);
assert!(weight.all_lt(block_weight));
}
}
12 changes: 11 additions & 1 deletion runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ impl module_homa::Config for Runtime {
type XcmInterface = XcmInterface;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
type NominationsProvider = NomineesElection;
type ProcessRedeemRequestsLimit = ConstU32<2_000>;
type ProcessRedeemRequestsLimit = ConstU32<1_000>;
}

parameter_types! {
Expand Down Expand Up @@ -2865,4 +2865,14 @@ mod tests {
);
});
}

#[test]
fn check_on_initialize_with_bump_era_weight() {
use module_homa::WeightInfo;
let weight = weights::module_homa::WeightInfo::<Runtime>::on_initialize_with_bump_era(
<Runtime as module_homa::Config>::ProcessRedeemRequestsLimit::get(),
);
let block_weight = RuntimeBlockWeights::get().max_block.div(3).mul(2);
assert!(weight.all_lt(block_weight));
}
}

0 comments on commit d9652d6

Please sign in to comment.