diff --git a/integration_tests/tests/features/indexer.feature b/integration_tests/tests/features/indexer.feature index 949c41c86..551b6a312 100644 --- a/integration_tests/tests/features/indexer.feature +++ b/integration_tests/tests/features/indexer.feature @@ -54,7 +54,7 @@ Feature: Indexer node Then I wait for the indexer INDEXER to sync with the network # Scan the network for the event emitted on ACC creation - When indexer INDEXER scans the network events for account ACC with topics std.component.created,std.vault.pay_fee,std.component.updated + When indexer INDEXER scans the network events for account ACC with topics std.component.created,Account.pay_fee,std.component.updated Scenario: Indexer GraphQL requests work # Initialize a base node, wallet, miner and VN @@ -75,10 +75,10 @@ Feature: Indexer node Then I wait for the indexer INDEXER to sync with the network ##### Scenario # Scan the network for the event emitted on ACC_1 creation - When indexer INDEXER scans the network events for account ACC_1 with topics std.component.created,std.vault.pay_fee + When indexer INDEXER scans the network events for account ACC_1 with topics std.component.created,Account.pay_fee # Scan the network for the event emitted on ACC_2 creation - When indexer INDEXER scans the network events for account ACC_2 with topics std.component.created,std.vault.pay_fee + When indexer INDEXER scans the network events for account ACC_2 with topics std.component.created,Account.pay_fee Scenario: Indexer GraphQL filtering and pagination of events Given a network with registered validator VN and wallet daemon WALLET_D diff --git a/integration_tests/tests/steps/indexer.rs b/integration_tests/tests/steps/indexer.rs index 779d2bb35..2cdbfb715 100644 --- a/integration_tests/tests/steps/indexer.rs +++ b/integration_tests/tests/steps/indexer.rs @@ -109,30 +109,46 @@ async fn indexer_scans_network_events( let account = world.wallet_accounts.get(&account_name).unwrap_or_else(|| { panic!("No wallet account found with name {}", account_name); }); - let mut graphql_client = indexer.get_graphql_indexer_client().await; - let query = r#"{ getEvents { substateId, templateAddress, txHash, topic, payload } }"#.to_string(); - let res = graphql_client - .send_request::>>(&query, None, None) - .await - .expect("Failed to obtain getEvents query result"); + let component_address = account.component_address().to_string(); + let expected_topics: Vec<&str> = topics_str.split(',').collect(); - let events = res.get("getEvents").unwrap(); - let topics_for_component = events - .iter() - .filter(|e| e.substate_id == Some(account.component_address().to_string())) - .map(|e| e.topic.as_str()) - .collect::>(); - - let expected_topics = topics_str.split(','); - for (ind, topic) in expected_topics.enumerate() { - assert!( - topics_for_component.contains(topic), - "Unexpected topic at index {}. Events emitted were {}. Expected topic {} (ALL {:?})", - ind, - topics_for_component.display(), - topic, - events - ); + let mut remaining = 30; + loop { + let mut graphql_client = indexer.get_graphql_indexer_client().await; + let query = r#"{ getEvents { substateId, templateAddress, txHash, topic, payload } }"#.to_string(); + let res = graphql_client + .send_request::>>(&query, None, None) + .await + .expect("Failed to obtain getEvents query result"); + + let events = res.get("getEvents").unwrap(); + let topics_for_component = events + .iter() + .filter(|e| e.substate_id == Some(component_address.clone())) + .map(|e| e.topic.as_str()) + .collect::>(); + + let all_found = expected_topics.iter().all(|topic| topics_for_component.contains(topic)); + if all_found { + return; + } + + if remaining == 0 { + // Report which topics were missing + for (ind, topic) in expected_topics.iter().enumerate() { + assert!( + topics_for_component.contains(topic), + "Unexpected topic at index {}. Events emitted were {}. Expected topic {} (ALL {:?})", + ind, + topics_for_component.display(), + topic, + events + ); + } + unreachable!(); + } + remaining -= 1; + tokio::time::sleep(std::time::Duration::from_secs(1)).await; } }