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")]
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum Chain {
|
pub enum Chain {
|
||||||
Mainnet = 1,
|
Mainnet = 1,
|
||||||
|
Morden = 2,
|
||||||
Ropsten = 3,
|
Ropsten = 3,
|
||||||
Rinkeby = 4,
|
Rinkeby = 4,
|
||||||
Goerli = 5,
|
Goerli = 5,
|
||||||
|
@ -61,6 +62,7 @@ impl fmt::Display for Chain {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let chain = match self {
|
let chain = match self {
|
||||||
Chain::Mainnet => "mainnet",
|
Chain::Mainnet => "mainnet",
|
||||||
|
Chain::Morden => "morden",
|
||||||
Chain::Ropsten => "ropsten",
|
Chain::Ropsten => "ropsten",
|
||||||
Chain::Rinkeby => "rinkeby",
|
Chain::Rinkeby => "rinkeby",
|
||||||
Chain::Goerli => "goerli",
|
Chain::Goerli => "goerli",
|
||||||
|
@ -125,6 +127,7 @@ impl TryFrom<u64> for Chain {
|
||||||
fn try_from(chain: u64) -> Result<Chain, Self::Error> {
|
fn try_from(chain: u64) -> Result<Chain, Self::Error> {
|
||||||
Ok(match chain {
|
Ok(match chain {
|
||||||
1 => Chain::Mainnet,
|
1 => Chain::Mainnet,
|
||||||
|
2 => Chain::Morden,
|
||||||
3 => Chain::Ropsten,
|
3 => Chain::Ropsten,
|
||||||
4 => Chain::Rinkeby,
|
4 => Chain::Rinkeby,
|
||||||
5 => Chain::Goerli,
|
5 => Chain::Goerli,
|
||||||
|
@ -180,6 +183,7 @@ impl FromStr for Chain {
|
||||||
fn from_str(chain: &str) -> Result<Self, Self::Err> {
|
fn from_str(chain: &str) -> Result<Self, Self::Err> {
|
||||||
Ok(match chain {
|
Ok(match chain {
|
||||||
"mainnet" => Chain::Mainnet,
|
"mainnet" => Chain::Mainnet,
|
||||||
|
"morden" => Chain::Morden,
|
||||||
"ropsten" => Chain::Ropsten,
|
"ropsten" => Chain::Ropsten,
|
||||||
"rinkeby" => Chain::Rinkeby,
|
"rinkeby" => Chain::Rinkeby,
|
||||||
"goerli" => Chain::Goerli,
|
"goerli" => Chain::Goerli,
|
||||||
|
|
|
@ -79,6 +79,7 @@ impl Client {
|
||||||
Chain::Avalanche | Chain::AvalancheFuji => std::env::var("SNOWTRACE_API_KEY")?,
|
Chain::Avalanche | Chain::AvalancheFuji => std::env::var("SNOWTRACE_API_KEY")?,
|
||||||
Chain::Polygon | Chain::PolygonMumbai => std::env::var("POLYGONSCAN_API_KEY")?,
|
Chain::Polygon | Chain::PolygonMumbai => std::env::var("POLYGONSCAN_API_KEY")?,
|
||||||
Chain::Mainnet |
|
Chain::Mainnet |
|
||||||
|
Chain::Morden |
|
||||||
Chain::Ropsten |
|
Chain::Ropsten |
|
||||||
Chain::Kovan |
|
Chain::Kovan |
|
||||||
Chain::Rinkeby |
|
Chain::Rinkeby |
|
||||||
|
@ -484,10 +485,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn chain_not_supported() {
|
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!(matches!(err, EtherscanError::ChainNotSupported(_)));
|
||||||
assert_eq!(err.to_string(), "Chain sepolia not supported");
|
assert_eq!(err.to_string(), "Chain morden not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue