From e76d4768120caae95d2d5ec520a61a7c2a17f5d8 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 27 Aug 2020 13:23:08 +1000 Subject: [PATCH] Fix validator id decoding --- beacon_node/http_api/tests/tests.rs | 17 +++++------------ common/eth2/src/types.rs | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index 1b9b47245c0..83af0744195 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -333,18 +333,11 @@ impl ApiTester { .unwrap() .map(|res| res.data); - let state = if let Some(state) = state_opt.as_ref() { - state - } else { - if result.is_none() { - continue; - } else { - panic!( - "should have returned none: {:?}, {:?}", - state_id, validator_id - ) - } - }; + if result.is_none() && state_opt.is_none() { + continue; + } + + let state = state_opt.as_ref().expect("result should be none"); let expected = { let epoch = state.current_epoch(); diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 8ebd7f2f04e..83c97b36719 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -144,7 +144,7 @@ impl FromStr for ValidatorId { fn from_str(s: &str) -> Result { if s.starts_with("0x") { - serde_json::from_str(s) + serde_json::from_str(&format!("\"{}\"", s)) .map(ValidatorId::PublicKey) .map_err(|_| format!("{} cannot be parsed as a public key", s)) } else {