From 71e35a7c34491d50135f870c7e1215ab527b3dcf Mon Sep 17 00:00:00 2001 From: refcell Date: Tue, 5 Nov 2024 18:37:56 -0500 Subject: [PATCH] fix(derive-alloy): test coverage (#785) --- .github/codecov.yml | 2 ++ crates/derive-alloy/src/errors.rs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/.github/codecov.yml b/.github/codecov.yml index f76d9ea1b..1d835ab63 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -23,6 +23,8 @@ ignore: - "**/test_utils*" - "**/test_util*" - "**/tests*" + - "crates/derive-alloy/src/alloy_providers.rs" + - "crates/derive-alloy/src/beacon_client.rs" - "crates/mpt/src/noop.rs" # Make comments less noisy diff --git a/crates/derive-alloy/src/errors.rs b/crates/derive-alloy/src/errors.rs index 5c433c776..8ede5b1c0 100644 --- a/crates/derive-alloy/src/errors.rs +++ b/crates/derive-alloy/src/errors.rs @@ -34,3 +34,27 @@ impl From for PipelineErrorKind { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_from_alloy_provider_error() { + let err: PipelineErrorKind = AlloyProviderError::Rlp(alloy_rlp::Error::Overflow).into(); + assert!(matches!(err, PipelineErrorKind::Critical(_))); + + let err: PipelineErrorKind = + AlloyProviderError::BlockInfo(FromBlockError::InvalidGenesisHash).into(); + assert!(matches!(err, PipelineErrorKind::Critical(_))); + + let err: PipelineErrorKind = AlloyProviderError::OpBlockConversion( + OpBlockConversionError::MissingSystemConfigGenesis, + ) + .into(); + assert!(matches!(err, PipelineErrorKind::Critical(_))); + + let err: PipelineErrorKind = AlloyProviderError::Rpc(RpcError::NullResp).into(); + assert!(matches!(err, PipelineErrorKind::Temporary(_))); + } +}