mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 05:45:41 +00:00
Fix storage parameter name computation (#1238)
* fixed storage_parameter_key * added test for storage_parameter_key
This commit is contained in:
committed by
Bastian Köcher
parent
1fb70c7ed7
commit
edd1724957
@@ -22,6 +22,9 @@ sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "
|
|||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
hex-literal = "0.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
|||||||
@@ -256,10 +256,22 @@ pub fn storage_map_final_key_identity(
|
|||||||
///
|
///
|
||||||
/// Copied from `frame_support::parameter_types` macro
|
/// Copied from `frame_support::parameter_types` macro
|
||||||
pub fn storage_parameter_key(parameter_name: &str) -> StorageKey {
|
pub fn storage_parameter_key(parameter_name: &str) -> StorageKey {
|
||||||
let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1 + 1);
|
let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1);
|
||||||
buffer.push(b':');
|
buffer.push(b':');
|
||||||
buffer.extend_from_slice(parameter_name.as_bytes());
|
buffer.extend_from_slice(parameter_name.as_bytes());
|
||||||
buffer.push(b':');
|
buffer.push(b':');
|
||||||
buffer.push(0);
|
|
||||||
StorageKey(sp_io::hashing::twox_128(&buffer).to_vec())
|
StorageKey(sp_io::hashing::twox_128(&buffer).to_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn storage_parameter_key_works() {
|
||||||
|
assert_eq!(
|
||||||
|
storage_parameter_key("MillauToRialtoConversionRate"),
|
||||||
|
StorageKey(hex_literal::hex!("58942375551bb0af1682f72786b59d04").to_vec()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user