From 7566c3d71e69553b609c1b0b9987a9c7d2df3035 Mon Sep 17 00:00:00 2001 From: sea-edge <39196461+sea-edge@users.noreply.github.com> Date: Mon, 11 Jul 2022 06:28:39 +0900 Subject: [PATCH] For fix test code, Added morden to chainid as a Mock-like value. (#1472) --- ethers-core/src/types/chain.rs | 4 ++++ ethers-etherscan/src/lib.rs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index 3a14caff..1831db54 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -18,6 +18,7 @@ pub struct ParseChainError(String); #[strum(serialize_all = "kebab-case")] pub enum Chain { Mainnet = 1, + Morden = 2, Ropsten = 3, Rinkeby = 4, Goerli = 5, @@ -61,6 +62,7 @@ impl fmt::Display for Chain { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let chain = match self { Chain::Mainnet => "mainnet", + Chain::Morden => "morden", Chain::Ropsten => "ropsten", Chain::Rinkeby => "rinkeby", Chain::Goerli => "goerli", @@ -125,6 +127,7 @@ impl TryFrom for Chain { fn try_from(chain: u64) -> Result { Ok(match chain { 1 => Chain::Mainnet, + 2 => Chain::Morden, 3 => Chain::Ropsten, 4 => Chain::Rinkeby, 5 => Chain::Goerli, @@ -180,6 +183,7 @@ impl FromStr for Chain { fn from_str(chain: &str) -> Result { Ok(match chain { "mainnet" => Chain::Mainnet, + "morden" => Chain::Morden, "ropsten" => Chain::Ropsten, "rinkeby" => Chain::Rinkeby, "goerli" => Chain::Goerli, diff --git a/ethers-etherscan/src/lib.rs b/ethers-etherscan/src/lib.rs index a1dde68c..a78483f0 100644 --- a/ethers-etherscan/src/lib.rs +++ b/ethers-etherscan/src/lib.rs @@ -79,6 +79,7 @@ impl Client { Chain::Avalanche | Chain::AvalancheFuji => std::env::var("SNOWTRACE_API_KEY")?, Chain::Polygon | Chain::PolygonMumbai => std::env::var("POLYGONSCAN_API_KEY")?, Chain::Mainnet | + Chain::Morden | Chain::Ropsten | Chain::Kovan | Chain::Rinkeby | @@ -484,10 +485,10 @@ mod tests { #[test] fn chain_not_supported() { - let err = Client::new_from_env(Chain::Sepolia).unwrap_err(); + let err = Client::new_from_env(Chain::Morden).unwrap_err(); assert!(matches!(err, EtherscanError::ChainNotSupported(_))); - assert_eq!(err.to_string(), "Chain sepolia not supported"); + assert_eq!(err.to_string(), "Chain morden not supported"); } #[test]