Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions src/event_scanner/scanner/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ use crate::{
};

impl EventScannerBuilder<LatestEvents> {
#[must_use]
pub fn block_confirmations(mut self, confirmations: u64) -> Self {
self.config.block_confirmations = confirmations;
self
}

/// Sets the starting block for the historic scan.
///
/// # Note
Expand Down Expand Up @@ -168,10 +162,7 @@ impl<N: Network> EventScanner<LatestEvents, N> {

#[cfg(test)]
mod tests {
use crate::{
block_range_scanner::DEFAULT_BLOCK_CONFIRMATIONS,
event_scanner::scanner::DEFAULT_MAX_CONCURRENT_FETCHES,
};
use crate::event_scanner::scanner::DEFAULT_MAX_CONCURRENT_FETCHES;

use super::*;
use alloy::{
Expand All @@ -187,13 +178,11 @@ mod tests {
fn test_latest_scanner_builder_pattern() {
let builder = EventScannerBuilder::latest(3)
.max_block_range(25)
.block_confirmations(5)
.from_block(BlockNumberOrTag::Number(50))
.to_block(BlockNumberOrTag::Number(150))
.max_concurrent_fetches(10);

assert_eq!(builder.block_range_scanner.max_block_range, 25);
assert_eq!(builder.config.block_confirmations, 5);
assert_eq!(builder.config.max_concurrent_fetches, 10);
assert_eq!(builder.config.count, 3);
assert_eq!(builder.config.from_block, BlockNumberOrTag::Number(50).into());
Expand All @@ -208,7 +197,6 @@ mod tests {
assert_eq!(builder.config.to_block, BlockNumberOrTag::Earliest.into());
assert_eq!(builder.config.count, 10);
assert_eq!(builder.config.max_concurrent_fetches, DEFAULT_MAX_CONCURRENT_FETCHES);
assert_eq!(builder.config.block_confirmations, DEFAULT_BLOCK_CONFIRMATIONS);
}

#[test]
Expand All @@ -218,8 +206,6 @@ mod tests {
.from_block(20)
.to_block(100)
.to_block(200)
.block_confirmations(5)
.block_confirmations(7)
.max_block_range(50)
.max_block_range(60)
.max_concurrent_fetches(10)
Expand All @@ -228,24 +214,10 @@ mod tests {
assert_eq!(builder.config.count, 3);
assert_eq!(builder.config.from_block, BlockNumberOrTag::Number(20).into());
assert_eq!(builder.config.to_block, BlockNumberOrTag::Number(200).into());
assert_eq!(builder.config.block_confirmations, 7);
assert_eq!(builder.config.max_concurrent_fetches, 20);
assert_eq!(builder.block_range_scanner.max_block_range, 60);
}

#[tokio::test]
async fn accepts_zero_confirmations() -> anyhow::Result<()> {
let anvil = Anvil::new().try_spawn().unwrap();
let provider = ProviderBuilder::new().connect_http(anvil.endpoint_url());

let scanner =
EventScannerBuilder::latest(1).block_confirmations(0).connect(provider).await?;

assert_eq!(scanner.config.block_confirmations, 0);

Ok(())
}

#[tokio::test]
async fn test_latest_returns_error_with_zero_count() {
let provider = RootProvider::<Ethereum>::new(RpcClient::mocked(Asserter::new()));
Expand Down
3 changes: 0 additions & 3 deletions src/event_scanner/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub struct LatestEvents {
pub(crate) count: usize,
pub(crate) from_block: BlockId,
pub(crate) to_block: BlockId,
pub(crate) block_confirmations: u64,
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
pub(crate) max_concurrent_fetches: usize,
}
Expand Down Expand Up @@ -378,7 +377,6 @@ impl EventScannerBuilder<LatestEvents> {
count,
from_block: BlockNumberOrTag::Latest.into(),
to_block: BlockNumberOrTag::Earliest.into(),
block_confirmations: DEFAULT_BLOCK_CONFIRMATIONS,
max_concurrent_fetches: DEFAULT_MAX_CONCURRENT_FETCHES,
},
block_range_scanner: BlockRangeScanner::default(),
Expand Down Expand Up @@ -510,7 +508,6 @@ mod tests {

assert_eq!(builder.config.from_block, BlockNumberOrTag::Latest.into());
assert_eq!(builder.config.to_block, BlockNumberOrTag::Earliest.into());
assert_eq!(builder.config.block_confirmations, DEFAULT_BLOCK_CONFIRMATIONS);
}

#[test]
Expand Down