Skip to content

Commit 66522d6

Browse files
committed
test: add missing assert_empty
1 parent 5444bc6 commit 66522d6

File tree

3 files changed

+15
-36
lines changed

3 files changed

+15
-36
lines changed

tests/live/basic.rs

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
use std::time::Duration;
2-
31
use crate::common::{TestCounter, deploy_counter, setup_live_scanner};
42
use alloy::{primitives::U256, sol_types::SolEvent};
53
use event_scanner::{EventFilter, assert_empty, assert_event_sequence};
6-
use tokio::time::timeout;
7-
use tokio_stream::StreamExt;
84

95
#[tokio::test]
106
async fn basic_single_event_scanning() -> anyhow::Result<()> {
@@ -124,63 +120,41 @@ async fn multiple_events_same_contract() -> anyhow::Result<()> {
124120
#[tokio::test]
125121
async fn signature_matching_ignores_irrelevant_events() -> anyhow::Result<()> {
126122
let setup = setup_live_scanner(Some(0.1), None, 0).await?;
127-
let contract = setup.contract.clone();
123+
let contract = setup.contract;
124+
let mut scanner = setup.scanner;
128125

129126
// Subscribe to CountDecreased but only emit CountIncreased
130127
let filter = EventFilter::new()
131128
.contract_address(*contract.address())
132129
.event(TestCounter::CountDecreased::SIGNATURE.to_owned());
133130

134-
let num_of_events = 3;
135-
136-
let mut scanner = setup.scanner;
137-
138-
let mut stream = scanner.subscribe(filter).take(num_of_events);
131+
let stream = scanner.subscribe(filter);
139132

140133
scanner.start().await?;
141134

142-
for _ in 0..num_of_events {
143-
contract.increase().send().await?.watch().await?;
144-
}
145-
146-
let event_counting = async move {
147-
_ = stream.next().await;
148-
};
135+
contract.increase().send().await?.watch().await?;
149136

150-
if timeout(Duration::from_secs(1), event_counting).await.is_ok() {
151-
anyhow::bail!("scanner should have ignored all of the emitted events");
152-
}
137+
assert_empty!(stream);
153138

154139
Ok(())
155140
}
156141

157142
#[tokio::test]
158143
async fn filters_malformed_signature_graceful() -> anyhow::Result<()> {
159144
let setup = setup_live_scanner(Some(0.1), None, 0).await?;
160-
let contract = setup.contract.clone();
145+
let contract = setup.contract;
146+
let mut scanner = setup.scanner;
161147

162148
let filter =
163149
EventFilter::new().contract_address(*contract.address()).event("invalid-sig".to_string());
164150

165-
let num_of_events = 3;
166-
167-
let mut scanner = setup.scanner;
168-
169-
let mut stream = scanner.subscribe(filter).take(num_of_events);
151+
let stream = scanner.subscribe(filter);
170152

171153
scanner.start().await?;
172154

173-
for _ in 0..num_of_events {
174-
contract.increase().send().await?.watch().await?;
175-
}
176-
177-
let event_counting = async move {
178-
_ = stream.next().await;
179-
};
155+
contract.increase().send().await?.watch().await?;
180156

181-
if timeout(Duration::from_secs(1), event_counting).await.is_ok() {
182-
anyhow::bail!("scanner should have ignored all of the emitted events");
183-
}
157+
assert_empty!(stream);
184158

185159
Ok(())
186160
}

tests/live/optional_fields.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async fn track_all_events_from_contract() -> anyhow::Result<()> {
4848
TestCounter::CountDecreased { newCount: U256::from(3) }
4949
]
5050
);
51+
assert_empty!(stream);
5152

5253
Ok(())
5354
}

tests/sync/from_latest.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async fn happy_path_no_duplicates() -> anyhow::Result<()> {
4444
TestCounter::CountIncreased { newCount: U256::from(8) }
4545
]
4646
);
47+
assert_empty!(stream);
4748

4849
Ok(())
4950
}
@@ -82,6 +83,7 @@ async fn fewer_historical_then_continues_live() -> anyhow::Result<()> {
8283
TestCounter::CountIncreased { newCount: U256::from(4) }
8384
]
8485
);
86+
assert_empty!(stream);
8587

8688
Ok(())
8789
}
@@ -144,6 +146,7 @@ async fn no_historical_only_live_streams() -> anyhow::Result<()> {
144146
TestCounter::CountIncreased { newCount: U256::from(2) }
145147
]
146148
);
149+
assert_empty!(stream);
147150

148151
Ok(())
149152
}
@@ -184,6 +187,7 @@ async fn block_gaps_do_not_affect_number_of_events_streamed() -> anyhow::Result<
184187
contract.increase().send().await?.watch().await?;
185188

186189
assert_next!(stream, &[TestCounter::CountIncreased { newCount: U256::from(4) }]);
190+
assert_empty!(stream);
187191

188192
Ok(())
189193
}

0 commit comments

Comments
 (0)