Skip to content

Commit edd1724

Browse files
svyatonikbkchr
authored andcommitted
Fix storage parameter name computation (#1238)
* fixed storage_parameter_key * added test for storage_parameter_key
1 parent 1fb70c7 commit edd1724

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

bridges/primitives/runtime/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "
2222
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
2323
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
2424

25+
[dev-dependencies]
26+
hex-literal = "0.3"
27+
2528
[features]
2629
default = ["std"]
2730
std = [

bridges/primitives/runtime/src/lib.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,22 @@ pub fn storage_map_final_key_identity(
256256
///
257257
/// Copied from `frame_support::parameter_types` macro
258258
pub fn storage_parameter_key(parameter_name: &str) -> StorageKey {
259-
let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1 + 1);
259+
let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1);
260260
buffer.push(b':');
261261
buffer.extend_from_slice(parameter_name.as_bytes());
262262
buffer.push(b':');
263-
buffer.push(0);
264263
StorageKey(sp_io::hashing::twox_128(&buffer).to_vec())
265264
}
265+
266+
#[cfg(test)]
267+
mod tests {
268+
use super::*;
269+
270+
#[test]
271+
fn storage_parameter_key_works() {
272+
assert_eq!(
273+
storage_parameter_key("MillauToRialtoConversionRate"),
274+
StorageKey(hex_literal::hex!("58942375551bb0af1682f72786b59d04").to_vec()),
275+
);
276+
}
277+
}

0 commit comments

Comments
 (0)