From 35c607f6beaf6ae4ef0cf29ced7b6aeb25dae6a1 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Mon, 17 Jun 2019 13:22:53 +0200 Subject: [PATCH] updater: fix static id hashes initialization (#10755) * updater: fix static id hashes initialization * Update updater/src/updater.rs --- 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 27daac4ed..6e84f8281 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; + } }