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,
|
||||
time::Duration,
|
||||
};
|
||||
use strum::{AsRefStr, EnumString, EnumVariantNames};
|
||||
use strum::{AsRefStr, EnumCount, EnumIter, EnumString, EnumVariantNames};
|
||||
|
||||
// compatibility re-export
|
||||
#[doc(hidden)]
|
||||
|
@ -33,6 +33,8 @@ pub type ParseChainError = TryFromPrimitiveError<Chain>;
|
|||
AsRefStr, // also for fmt::Display and serde::Serialize
|
||||
EnumVariantNames, // Self::VARIANTS
|
||||
EnumString, // FromStr, TryFrom<&str>
|
||||
EnumIter,
|
||||
EnumCount,
|
||||
TryFromPrimitive, // TryFrom<u64>
|
||||
Deserialize,
|
||||
)]
|
||||
|
@ -372,9 +374,15 @@ impl Chain {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
#[test]
|
||||
fn test_default_chain() {
|
||||
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");
|
||||
|
||||
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 non_existing = path.join("test.sol");
|
||||
std::fs::write(
|
||||
&existing,
|
||||
existing,
|
||||
r#"
|
||||
pragma solidity ^0.8.10;
|
||||
contract A {}
|
||||
|
|
|
@ -19,7 +19,7 @@ async fn main() -> eyre::Result<()> {
|
|||
.rate_limit_retries(10)
|
||||
.timeout_retries(3)
|
||||
.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
|
||||
let block_num = "latest".to_string();
|
||||
|
|
Loading…
Reference in New Issue