For fix test code, Added morden to chainid as a Mock-like value. (#1472)
This commit is contained in:
parent
d12c98d0cc
commit
7566c3d71e
|
@ -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,
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue