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

This commit is contained in:
sea-edge 2022-07-11 06:28:39 +09:00 committed by GitHub
parent d12c98d0cc
commit 7566c3d71e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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<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,
@ -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,

View File

@ -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]