Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

For fix test code, Added morden to chainid as a Mock-like value. #1472

Merged
merged 1 commit into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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