Skip to content

Commit

Permalink
Fix all broken tests with updated deployments and indexers
Browse files Browse the repository at this point in the history
Signed-off-by: Filippo Costa <[email protected]>
  • Loading branch information
neysofu committed Dec 15, 2024
1 parent ff156b5 commit 622323d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
14 changes: 14 additions & 0 deletions crates/graphix_lib/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ use url::Url;

use crate::config::IndexerConfig;

pub mod deployments {
pub const ARB1_PREMIA_BLUE: &str = "QmdHQVHirs3yPygcgo3HNttXaFCS4pnoGiMx3aKXr192En";
pub const ARB1_QUICKSWAP_V3: &str = "QmQEYSGSD8t7jTw4gS2dwC4DLvyZceR9fYQ432Ff1hZpCp";
pub const ARB1_LIDO: &str = "Qmd3vU6y6pxxXPrvVWRZMN9soNB8AFQCEnqPa9jMSZZDEG";

/// Extremely low curation signal, basically no indexer has it.
pub const FUSE_TO_ETHEREUM_AMB: &str = "QmYU3Exnta8H52vWUFhGQi6Qm8LhXr5LqmypNrLba8rRem";
}

pub mod indexers {
pub const ARB1_DATA_NEXUS: &str = "https://arb-service.thegraph.datanexus.tech/";
pub const ARB1_ELLIPFRA: &str = "https://graph-l2prod.ellipfra.com/";
}

pub static TEST_SEED: Lazy<u64> = Lazy::new(|| {
let seed = env::var("TEST_SEED")
.map(|seed| seed.parse().expect("Invalid TEST_SEED value"))
Expand Down
6 changes: 3 additions & 3 deletions crates/graphix_lib/tests/it_indexing_statuses.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::time::Duration;

use graphix_indexer_client::IndexerClient;
use graphix_lib::test_utils::{ipfs_cid, test_indexer_from_url};
use graphix_lib::test_utils::{deployments, indexers, ipfs_cid, test_indexer_from_url};

#[tokio::test]
async fn send_indexer_statuses_query() {
//// Given
let indexer = test_indexer_from_url("https://testnet-indexer-03-europe-cent.thegraph.com");
let indexer = test_indexer_from_url(indexers::ARB1_DATA_NEXUS);

let test_deployment = ipfs_cid("QmeYTH2fK2wv96XvnCGH2eyKFE8kmRfo53zYVy5dKysZtH");
let test_deployment = ipfs_cid(deployments::ARB1_QUICKSWAP_V3);

//// When
let request_fut = IndexerClient::indexing_statuses(indexer);
Expand Down
33 changes: 19 additions & 14 deletions crates/graphix_lib/tests/it_proofs_of_indexing.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::time::Duration;

use graphix_indexer_client::{IndexerClient, PoiRequest};
use graphix_lib::test_utils::{ipfs_cid, test_indexer_from_url};
use graphix_lib::test_utils::{deployments, indexers, ipfs_cid, test_indexer_from_url};

#[tokio::test]
async fn send_single_query_and_process_result() {
//// Given
let indexer = test_indexer_from_url("https://testnet-indexer-03-europe-cent.thegraph.com");
let indexer = test_indexer_from_url(indexers::ARB1_DATA_NEXUS);

let deployment = ipfs_cid("QmeYTH2fK2wv96XvnCGH2eyKFE8kmRfo53zYVy5dKysZtH");
let deployment = ipfs_cid(deployments::ARB1_PREMIA_BLUE);

let poi_request = PoiRequest {
deployment: deployment.clone(),
Expand All @@ -32,9 +32,9 @@ async fn send_single_query_and_process_result() {
#[tokio::test]
async fn send_single_query_of_unknown_deployment_id_and_handle_error() {
//// Given
let indexer = test_indexer_from_url("https://testnet-indexer-03-europe-cent.thegraph.com");
let indexer = test_indexer_from_url(indexers::ARB1_DATA_NEXUS);

let deployment_unknown = ipfs_cid("Qmd3vU6y6pxxXPrvVWRZMN9soNB8AFQCEnqPa9jMSZZDEG");
let deployment_unknown = ipfs_cid(deployments::FUSE_TO_ETHEREUM_AMB);

let poi_request = PoiRequest {
deployment: deployment_unknown.clone(),
Expand All @@ -59,9 +59,9 @@ async fn send_single_query_of_unknown_deployment_id_and_handle_error() {
#[tokio::test]
async fn send_single_query_of_unknown_block_number_and_handle_error() {
//// Given
let indexer = test_indexer_from_url("https://testnet-indexer-03-europe-cent.thegraph.com");
let indexer = test_indexer_from_url(indexers::ARB1_DATA_NEXUS);

let deployment = ipfs_cid("QmeYTH2fK2wv96XvnCGH2eyKFE8kmRfo53zYVy5dKysZtH");
let deployment = ipfs_cid(deployments::ARB1_QUICKSWAP_V3);

let poi_request = PoiRequest {
deployment: deployment.clone(),
Expand All @@ -87,13 +87,16 @@ async fn send_single_query_of_unknown_block_number_and_handle_error() {
async fn send_multiple_queries_and_process_results() {
// Given

// FIXME: This is temporarily set to 1 until we fix the error: 'Null value resolved for
// non-null field `proofOfIndexing`' Which is probably a Graph Node bug. Setting it to 1
// reduces the impact of this issue.
const MAX_REQUESTS_PER_QUERY: usize = 1;

let indexer = test_indexer_from_url("https://testnet-indexer-03-europe-cent.thegraph.com");
let indexer = test_indexer_from_url(indexers::ARB1_DATA_NEXUS);

let deployment = ipfs_cid("QmeYTH2fK2wv96XvnCGH2eyKFE8kmRfo53zYVy5dKysZtH");
let deployment = ipfs_cid(deployments::ARB1_QUICKSWAP_V3);

let poi_requests = (1..=MAX_REQUESTS_PER_QUERY)
let poi_requests = (1..=MAX_REQUESTS_PER_QUERY + 2)
.map(|i| PoiRequest {
deployment: deployment.clone(),
block_number: i as u64,
Expand Down Expand Up @@ -124,11 +127,11 @@ async fn send_multiple_queries_and_process_results() {
#[tokio::test]
async fn send_multiple_queries_of_unknown_deployment_id_and_process_results() {
//// Given
let indexer = test_indexer_from_url("https://testnet-indexer-03-europe-cent.thegraph.com");
let indexer = test_indexer_from_url(indexers::ARB1_DATA_NEXUS);

let deployment0 = ipfs_cid("QmeYTH2fK2wv96XvnCGH2eyKFE8kmRfo53zYVy5dKysZtH");
let deployment1 = ipfs_cid("QmawxQJ5U1JvgosoFVDyAwutLWxrckqVmBTQxaMaKoj3Lw");
let deployment_unknown = ipfs_cid("Qmd3vU6y6pxxXPrvVWRZMN9soNB8AFQCEnqPa9jMSZZDEG");
let deployment0 = ipfs_cid(deployments::ARB1_PREMIA_BLUE);
let deployment1 = ipfs_cid(deployments::ARB1_QUICKSWAP_V3);
let deployment_unknown = ipfs_cid(deployments::FUSE_TO_ETHEREUM_AMB);

let poi_requests = vec![
PoiRequest {
Expand All @@ -151,6 +154,8 @@ async fn send_multiple_queries_of_unknown_deployment_id_and_process_results() {
.await
.expect("Timeout");

println!("response: {:?}", response);

//// Then
assert_eq!(response.len(), 2);

Expand Down
9 changes: 4 additions & 5 deletions crates/network_sg_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl NetworkSubgraphClient {
#[serde(rename_all = "camelCase")]
struct IndexerData {
url: String,
default_display_name: String,
default_display_name: Option<String>,
}

let indexer_data = response_data
Expand All @@ -147,7 +147,7 @@ impl NetworkSubgraphClient {
.ok_or_else(|| anyhow::anyhow!("No indexer found for address {}", address))?;

let indexer = RealIndexer::new(
Some(indexer_data.default_display_name.clone()),
indexer_data.default_display_name.clone(),
*address,
Url::parse(&format!("{}/status", indexer_data.url))?.to_string(),
self.public_poi_requests.clone(),
Expand Down Expand Up @@ -397,9 +397,8 @@ mod tests {
#[tokio::test]
async fn mainnet_fetch_ellipfra() {
let client = network_sg_client_on_ethereum();
// ellipfra.eth:
// htps://thegraph.com/explorer/profile/0x62a0bd1d110ff4e5b793119e95fc07c9d1fc8c4a?view=Indexing&chain=mainnet
let address = str::parse("62a0bd1d110ff4e5b793119e95fc07c9d1fc8c4a").unwrap();
// htps://thegraph.com/explorer/profile/0x...?view=Indexing&chain=mainnet
let address = str::parse("f92f430dd8567b0d466358c79594ab58d919a6d4").unwrap();
let indexer = client.indexer_by_address(&address).await.unwrap();
assert_eq!(indexer.address(), address);
}
Expand Down

0 comments on commit 622323d

Please sign in to comment.