mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 13:15:41 +00:00
srml: consensus: kill storage (#2098)
* srml: consensus: kill storage items * srml: consensus: add test for set and kill storage * runtime: bump spec_version update wasm blobs
This commit is contained in:
BIN
Binary file not shown.
@@ -58,8 +58,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
spec_name: create_runtime_str!("node"),
|
spec_name: create_runtime_str!("node"),
|
||||||
impl_name: create_runtime_str!("substrate-node"),
|
impl_name: create_runtime_str!("substrate-node"),
|
||||||
authoring_version: 10,
|
authoring_version: 10,
|
||||||
spec_version: 43,
|
spec_version: 44,
|
||||||
impl_version: 43,
|
impl_version: 44,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -51,6 +51,7 @@ impl<S: codec::Codec + Default> StorageVec for AuthorityStorageVec<S> {
|
|||||||
const PREFIX: &'static [u8] = well_known_keys::AUTHORITY_PREFIX;
|
const PREFIX: &'static [u8] = well_known_keys::AUTHORITY_PREFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type Key = Vec<u8>;
|
||||||
pub type KeyValue = (Vec<u8>, Vec<u8>);
|
pub type KeyValue = (Vec<u8>, Vec<u8>);
|
||||||
|
|
||||||
/// Handling offline validator reports in a generic way.
|
/// Handling offline validator reports in a generic way.
|
||||||
@@ -216,6 +217,13 @@ decl_module! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Kill some items from storage.
|
||||||
|
fn kill_storage(keys: Vec<Key>) {
|
||||||
|
for key in &keys {
|
||||||
|
storage::unhashed::kill(&key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn on_finalise() {
|
fn on_finalise() {
|
||||||
if let Some(original_authorities) = <OriginalAuthorities<T>>::take() {
|
if let Some(original_authorities) = <OriginalAuthorities<T>>::take() {
|
||||||
let current_authorities = AuthorityStorageVec::<T::SessionKey>::items();
|
let current_authorities = AuthorityStorageVec::<T::SessionKey>::items();
|
||||||
|
|||||||
@@ -83,3 +83,28 @@ fn offline_report_can_be_excluded() {
|
|||||||
assert!(Consensus::create_inherent(&data).is_some());
|
assert!(Consensus::create_inherent(&data).is_some());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_and_kill_storage_work() {
|
||||||
|
use srml_support::storage;
|
||||||
|
|
||||||
|
with_externalities(&mut new_test_ext(vec![1, 2, 3]), || {
|
||||||
|
System::initialise(&1, &Default::default(), &Default::default());
|
||||||
|
|
||||||
|
let item = (vec![42u8], vec![42u8]);
|
||||||
|
|
||||||
|
Consensus::set_storage(vec![item.clone()]).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
storage::unhashed::get_raw(&item.0),
|
||||||
|
Some(item.1),
|
||||||
|
);
|
||||||
|
|
||||||
|
Consensus::kill_storage(vec![item.0.clone()]).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
storage::unhashed::get_raw(&item.0),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user