Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 911f122

Browse files
Consume the rest of the block and add test verification after the benchmark
1 parent 37d21f9 commit 911f122

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

frame/system/benchmarking/src/lib.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use codec::Encode;
2323
use frame_benchmarking::v1::{benchmarks, whitelisted_caller};
2424
use frame_support::{dispatch::DispatchClass, storage, traits::Get};
25-
use frame_system::{Call, EventRecord, Pallet as System, Phase, RawOrigin};
25+
use frame_system::{Call, Pallet as System, RawOrigin};
2626
use sp_core::storage::well_known_keys;
2727
use sp_runtime::traits::Hash;
2828
use sp_std::{prelude::*, vec};
@@ -52,14 +52,7 @@ benchmarks! {
5252
let runtime_blob = include_bytes!("../res/kitchensink_runtime.compact.compressed.wasm");
5353
}: _(RawOrigin::Root, runtime_blob.to_vec())
5454
verify {
55-
assert_eq!(
56-
System::<T>::events(),
57-
vec![EventRecord {
58-
phase: Phase::Initialization,
59-
event: frame_system::Event::<T>::CodeUpdated.into(),
60-
topics: vec![],
61-
}],
62-
);
55+
System::<T>::assert_last_event(frame_system::Event::<T>::CodeUpdated.into());
6356
}
6457

6558
#[extra]

frame/system/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ pub mod pallet {
412412
ensure_root(origin)?;
413413
Self::can_set_code(&code)?;
414414
T::OnSetCode::set_code(code)?;
415-
Ok(().into())
415+
// consume the rest of the block to prevent further transactions
416+
Ok(Some(T::BlockWeights::get().max_block).into())
416417
}
417418

418419
/// Set the new runtime code without doing any checks of the given `code`.

0 commit comments

Comments
 (0)