feat(core): add `strum::EnumIter` and `strum::EnumCount` to `Chain` (#2043)
* add strum EnumIter and EnumCount to Chain * clippy
This commit is contained in:
parent
a1d6b5e3f7
commit
3c65997eae
|
@ -5,7 +5,7 @@ use std::{
|
||||||
fmt,
|
fmt,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use strum::{AsRefStr, EnumString, EnumVariantNames};
|
use strum::{AsRefStr, EnumCount, EnumIter, EnumString, EnumVariantNames};
|
||||||
|
|
||||||
// compatibility re-export
|
// compatibility re-export
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -33,6 +33,8 @@ pub type ParseChainError = TryFromPrimitiveError<Chain>;
|
||||||
AsRefStr, // also for fmt::Display and serde::Serialize
|
AsRefStr, // also for fmt::Display and serde::Serialize
|
||||||
EnumVariantNames, // Self::VARIANTS
|
EnumVariantNames, // Self::VARIANTS
|
||||||
EnumString, // FromStr, TryFrom<&str>
|
EnumString, // FromStr, TryFrom<&str>
|
||||||
|
EnumIter,
|
||||||
|
EnumCount,
|
||||||
TryFromPrimitive, // TryFrom<u64>
|
TryFromPrimitive, // TryFrom<u64>
|
||||||
Deserialize,
|
Deserialize,
|
||||||
)]
|
)]
|
||||||
|
@ -372,9 +374,15 @@ impl Chain {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default_chain() {
|
fn test_default_chain() {
|
||||||
assert_eq!(serde_json::to_string(&Chain::default()).unwrap(), "\"mainnet\"");
|
assert_eq!(serde_json::to_string(&Chain::default()).unwrap(), "\"mainnet\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_enum_iter() {
|
||||||
|
assert_eq!(Chain::COUNT, Chain::iter().size_hint().0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,7 +512,7 @@ mod tests {
|
||||||
let source_maps = include_str!("../test-data/out-source-maps.txt");
|
let source_maps = include_str!("../test-data/out-source-maps.txt");
|
||||||
|
|
||||||
for (line, s) in source_maps.lines().enumerate() {
|
for (line, s) in source_maps.lines().enumerate() {
|
||||||
parse(s).unwrap_or_else(|_| panic!("Failed to parse line {}", line));
|
parse(s).unwrap_or_else(|_| panic!("Failed to parse line {line}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ mod tests {
|
||||||
let existing = path.join("Test.sol");
|
let existing = path.join("Test.sol");
|
||||||
let non_existing = path.join("test.sol");
|
let non_existing = path.join("test.sol");
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
&existing,
|
existing,
|
||||||
r#"
|
r#"
|
||||||
pragma solidity ^0.8.10;
|
pragma solidity ^0.8.10;
|
||||||
contract A {}
|
contract A {}
|
||||||
|
|
|
@ -19,7 +19,7 @@ async fn main() -> eyre::Result<()> {
|
||||||
.rate_limit_retries(10)
|
.rate_limit_retries(10)
|
||||||
.timeout_retries(3)
|
.timeout_retries(3)
|
||||||
.initial_backoff(Duration::from_millis(500))
|
.initial_backoff(Duration::from_millis(500))
|
||||||
.build(provider, Box::new(HttpRateLimitRetryPolicy::default()));
|
.build(provider, Box::<ethers::providers::HttpRateLimitRetryPolicy>::default());
|
||||||
|
|
||||||
// Send a JSON-RPC request for the latest block
|
// Send a JSON-RPC request for the latest block
|
||||||
let block_num = "latest".to_string();
|
let block_num = "latest".to_string();
|
||||||
|
|
Loading…
Reference in New Issue