diff --git a/testool/src/statetest/yaml.rs b/testool/src/statetest/yaml.rs index 7654632911..867e6b5423 100644 --- a/testool/src/statetest/yaml.rs +++ b/testool/src/statetest/yaml.rs @@ -290,28 +290,21 @@ impl<'a> YamlStateTestBuilder<'a> { } /// returns the element as an address fn parse_address(yaml: &Yaml) -> Result
{ - if let Some(as_str) = yaml.as_str() { - parse::parse_address(as_str) - } else if let Some(as_i64) = yaml.as_i64() { - let hex = format!("{as_i64:0>40}"); - Ok(Address::from_slice(&hex::decode(hex)?)) - } else if let Yaml::Real(as_real) = yaml { - Ok(Address::from_str(as_real)?) - } else { - bail!("cannot parse address {yaml:?}"); + match yaml { + Yaml::Real(real) => Ok(Address::from_str(real)?), + Yaml::Integer(int) => { + let hex = format!("{int:0>40}"); + Ok(Address::from_slice(&hex::decode(hex)?)) + } + Yaml::String(str) => parse::parse_address(str), + _ => bail!("cannot parse address {yaml:?}"), } } /// returns the element as a to address fn parse_to_address(yaml: &Yaml) -> Result> { - if let Some(as_str) = yaml.as_str() { - if as_str.trim().is_empty() { - return Ok(None); - } - parse::parse_to_address(as_str) - } else { - bail!("cannot parse to address {:?}", yaml); - } + let as_str = yaml.as_str().context("to_address_as_str")?; + parse::parse_to_address(as_str) } /// returns the element as an array of bytes @@ -323,28 +316,24 @@ impl<'a> YamlStateTestBuilder<'a> { /// returns the element as calldata bytes, supports 0x, :raw, :abi, :yul and /// { LLL } fn parse_calldata(&mut self, yaml: &Yaml) -> Result<(Bytes, Option