From 7d75597030ff0a874018b2727377dfb1e0bdae23 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Mon, 17 Jun 2019 11:55:51 +0200 Subject: [PATCH 1/2] updater: fix static id hashes initialization --- updater/src/updater.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/updater/src/updater.rs b/updater/src/updater.rs index 27daac4edb8..c34fefbe4ea 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -159,7 +159,7 @@ pub struct Updater H256 { + let mut bytes = s.as_bytes().to_vec(); + bytes.resize(H256::len_bytes(), 0); + H256::from_slice(&bytes) } /// Client trait for getting latest release information from operations contract. @@ -1253,4 +1262,11 @@ pub mod tests { // and since our update policy requires consensus, the client should be disabled assert!(client.is_disabled()); } + + #[test] + fn static_hashes_do_not_panic() { + let client_id_hash: H256 = *CLIENT_ID_HASH; + assert_eq!(&format!("{:x}", client_id_hash), "7061726974790000000000000000000000000000000000000000000000000000"); + let _: H256 = *PLATFORM_ID_HASH; + } } From 0eebde28ea8775247e9dab36407098a6cd30e81f Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Mon, 17 Jun 2019 12:57:43 +0200 Subject: [PATCH 2/2] Update updater/src/updater.rs --- updater/src/updater.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updater/src/updater.rs b/updater/src/updater.rs index c34fefbe4ea..6e84f8281e9 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -182,7 +182,7 @@ lazy_static! { // Pads the bytes with zeros or truncates the last bytes to H256::len_bytes() -// before the convertion to match the previous behavior. +// before the conversion to match the previous behavior. fn h256_from_str_resizing(s: &str) -> H256 { let mut bytes = s.as_bytes().to_vec(); bytes.resize(H256::len_bytes(), 0);