Skip to content

Commit

Permalink
For fix test code, Added morden to chainid as a Mock-like value. (gak…
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-edge authored Jul 10, 2022
1 parent d12c98d commit 7566c3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -125,6 +127,7 @@ impl TryFrom<u64> for Chain {
fn try_from(chain: u64) -> Result<Chain, Self::Error> {
Ok(match chain {
1 => Chain::Mainnet,
2 => Chain::Morden,
3 => Chain::Ropsten,
4 => Chain::Rinkeby,
5 => Chain::Goerli,
Expand Down Expand Up @@ -180,6 +183,7 @@ impl FromStr for Chain {
fn from_str(chain: &str) -> Result<Self, Self::Err> {
Ok(match chain {
"mainnet" => Chain::Mainnet,
"morden" => Chain::Morden,
"ropsten" => Chain::Ropsten,
"rinkeby" => Chain::Rinkeby,
"goerli" => Chain::Goerli,
Expand Down
5 changes: 3 additions & 2 deletions ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 7566c3d

Please sign in to comment.