This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: get_logs_paginated fetches past latest block (#1818)
- Loading branch information
Showing
3 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![cfg(not(target_arch = "wasm32"))] | ||
use ethers_core::{ | ||
types::{Filter, BlockNumber}, | ||
utils::Anvil, | ||
}; | ||
use ethers_providers::{Http, Middleware, Provider, StreamExt}; | ||
use std::convert::TryFrom; | ||
|
||
#[tokio::test] | ||
async fn get_logs_paginated() { | ||
let geth = Anvil::new().block_time(20u64).spawn(); | ||
let provider = Provider::<Http>::try_from(geth.endpoint()).unwrap(); | ||
|
||
let filter = Filter::new().from_block(BlockNumber::Latest); | ||
// try to get beyond the number of blocks available | ||
let mut stream = provider.get_logs_paginated(&filter, 10); | ||
let res = stream.next().await; | ||
assert!(res.is_some()); | ||
let log = res.unwrap(); | ||
assert!(log.is_ok()); | ||
} |