mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Emit log on Runtime Code change. (#9580)
* Emit digest item on Runtime Code changes. * Add tests. * cargo +nightly fmt --all * Rename. * Add comment. * Move generic parameter to the trait. * cargo +nightly fmt --all * Elaborate in doc. * Revert to RuntimeUpdated name * cargo +nightly fmt --all * Rename to RuntimeEnvironmentUpdated
This commit is contained in:
@@ -390,11 +390,24 @@ fn set_code_checks_works() {
|
||||
ext.execute_with(|| {
|
||||
let res = System::set_code(RawOrigin::Root.into(), vec![1, 2, 3, 4]);
|
||||
|
||||
assert_runtime_updated_digest(if res.is_ok() { 1 } else { 0 });
|
||||
assert_eq!(expected.map_err(DispatchErrorWithPostInfo::from), res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_runtime_updated_digest(num: usize) {
|
||||
assert_eq!(
|
||||
System::digest()
|
||||
.logs
|
||||
.into_iter()
|
||||
.filter(|item| *item == generic::DigestItem::RuntimeEnvironmentUpdated)
|
||||
.count(),
|
||||
num,
|
||||
"Incorrect number of Runtime Updated digest items",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_code_with_real_wasm_blob() {
|
||||
let executor = substrate_test_runtime_client::new_native_executor();
|
||||
@@ -478,3 +491,12 @@ fn extrinsics_root_is_calculated_correctly() {
|
||||
assert_eq!(ext_root, *header.extrinsics_root());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_updated_digest_emitted_when_heap_pages_changed() {
|
||||
new_test_ext().execute_with(|| {
|
||||
System::initialize(&1, &[0u8; 32].into(), &Default::default(), InitKind::Full);
|
||||
System::set_heap_pages(RawOrigin::Root.into(), 5).unwrap();
|
||||
assert_runtime_updated_digest(1);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user