Skip to content

Commit aa77e4d

Browse files
ArniStarkwareguy-starkware
authored andcommitted
apollo_integration_tests: readable expect fail on scraper end to end
1 parent d3ea928 commit aa77e4d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

crates/apollo_integration_tests/tests/l1_events_scraper_end_to_end.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use apollo_l1_provider::event_identifiers_to_track;
88
use apollo_l1_provider::l1_scraper::L1Scraper;
99
use apollo_l1_provider_types::{Event, MockL1ProviderClient};
1010
use apollo_l1_scraper_config::config::L1ScraperConfig;
11-
use mockall::predicate::eq;
1211
use mockall::Sequence;
1312
use papyrus_base_layer::test_utils::DEFAULT_ANVIL_L1_ACCOUNT_ADDRESS;
1413
use papyrus_base_layer::BaseLayerContract;
@@ -20,6 +19,15 @@ use starknet_api::hash::StarkHash;
2019
use starknet_api::transaction::fields::{Calldata, Fee};
2120
use starknet_api::transaction::{L1HandlerTransaction, TransactionHasher, TransactionVersion};
2221

22+
fn check_events_eq(expected: &[Event], actual: &[Event]) -> bool {
23+
if expected != actual {
24+
println!("Expected: {expected:?}\nActual: {actual:?}");
25+
return false;
26+
}
27+
28+
true
29+
}
30+
2331
#[tokio::test]
2432
async fn scraper_end_to_end() {
2533
// Setup.
@@ -137,15 +145,22 @@ async fn scraper_end_to_end() {
137145

138146
let mut sequence = Sequence::new();
139147
// Expect first call to return all the events defined further down.
148+
let expected_events_first_call =
149+
[first_expected_log, second_expected_log, expected_cancel_message];
140150
l1_provider_client
141151
.expect_add_events()
142152
.once()
143153
.in_sequence(&mut sequence)
144-
.with(eq(vec![first_expected_log, second_expected_log, expected_cancel_message]))
154+
.withf(move |actual| check_events_eq(&expected_events_first_call, actual))
145155
.returning(|_| Ok(()));
146156

147157
// Expect second call to return nothing, no events left to scrape.
148-
l1_provider_client.expect_add_events().once().in_sequence(&mut sequence).returning(|_| Ok(()));
158+
l1_provider_client
159+
.expect_add_events()
160+
.once()
161+
.in_sequence(&mut sequence)
162+
.withf(move |actual| check_events_eq(&[], actual))
163+
.returning(|_| Ok(()));
149164

150165
let l1_scraper_config = L1ScraperConfig {
151166
// Start scraping far enough back to capture all of the events created before.

0 commit comments

Comments
 (0)