mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
on_initialize return weight consumed and default cost to default DispatchInfo instead of zero (#5382)
* frame update * doc * move offchain worker trait also * fix weigh merge * indentation * reorder for better git diff * comment * fix benchmark * remove test
This commit is contained in:
@@ -935,6 +935,7 @@ impl_runtime_apis! {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use frame_system::offchain::{SignAndSubmitTransaction, SubmitSignedTransaction};
|
||||
use frame_support::traits::OnInitialize;
|
||||
|
||||
#[test]
|
||||
fn validate_transaction_submitter_bounds() {
|
||||
@@ -958,36 +959,4 @@ mod tests {
|
||||
is_submit_signed_transaction::<SubmitTransaction>();
|
||||
is_sign_and_submit_transaction::<SubmitTransaction>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn block_hooks_weight_should_not_exceed_limits() {
|
||||
use frame_support::weights::WeighBlock;
|
||||
let check_for_block = |b| {
|
||||
let block_hooks_weight =
|
||||
<AllModules as WeighBlock<BlockNumber>>::on_initialize(b) +
|
||||
<AllModules as WeighBlock<BlockNumber>>::on_finalize(b);
|
||||
|
||||
assert_eq!(
|
||||
block_hooks_weight,
|
||||
0,
|
||||
"This test might fail simply because the value being compared to has increased to a \
|
||||
module declaring a new weight for a hook or call. In this case update the test and \
|
||||
happily move on.",
|
||||
);
|
||||
|
||||
// Invariant. Always must be like this to have a sane chain.
|
||||
assert!(block_hooks_weight < MaximumBlockWeight::get());
|
||||
|
||||
// Warning.
|
||||
if block_hooks_weight > MaximumBlockWeight::get() / 2 {
|
||||
println!(
|
||||
"block hooks weight is consuming more than a block's capacity. You probably want \
|
||||
to re-think this. This test will fail now."
|
||||
);
|
||||
assert!(false);
|
||||
}
|
||||
};
|
||||
|
||||
let _ = (0..100_000).for_each(check_for_block);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user