From 207bfa04863b141f062e2c47b30597fb3248f6d4 Mon Sep 17 00:00:00 2001 From: Sergiu Popescu <44298302+sergiupopescu199@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:59:59 +0100 Subject: [PATCH] fix(iota-indexer): fix failing test (#4173) * fix(iota-indexer): fix failing test * fixup! fix(iota-indexer): fix failing test * fixup! fixup! fix(iota-indexer): fix failing test * fixup! fixup! fixup! fix(iota-indexer): fix failing test * fix(*): add rest api sync flag * fix(*): fallback to rest api * Update crates/iota-indexer/src/test_utils.rs Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> * fixup! fix(*): fallback to rest api --------- Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> --- crates/iota-cluster-test/src/cluster.rs | 4 ++-- crates/iota-indexer/src/test_utils.rs | 9 ++++++--- crates/iota-indexer/tests/common/mod.rs | 6 +++--- crates/iota-indexer/tests/rpc-tests/read_api.rs | 1 + crates/iota/src/iota_commands.rs | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/iota-cluster-test/src/cluster.rs b/crates/iota-cluster-test/src/cluster.rs index 20eee208d0b..3c1d993f992 100644 --- a/crates/iota-cluster-test/src/cluster.rs +++ b/crates/iota-cluster-test/src/cluster.rs @@ -264,7 +264,7 @@ impl Cluster for LocalNewCluster { Some(pg_address.clone()), fullnode_url.clone(), ReaderWriterConfig::writer_mode(None), - data_ingestion_path.clone(), + Some(data_ingestion_path.clone()), None, ) .await; @@ -274,7 +274,7 @@ impl Cluster for LocalNewCluster { Some(pg_address), fullnode_url.clone(), ReaderWriterConfig::reader_mode(indexer_address.to_string()), - data_ingestion_path, + Some(data_ingestion_path), None, ) .await; diff --git a/crates/iota-indexer/src/test_utils.rs b/crates/iota-indexer/src/test_utils.rs index 4058acc5634..3d9bf3f80cc 100644 --- a/crates/iota-indexer/src/test_utils.rs +++ b/crates/iota-indexer/src/test_utils.rs @@ -44,7 +44,7 @@ pub async fn start_test_indexer( db_url: Option, rpc_url: String, reader_writer_config: ReaderWriterConfig, - data_ingestion_path: PathBuf, + data_ingestion_path: Option, new_database: Option<&str>, ) -> (PgIndexerStore, JoinHandle>) { start_test_indexer_impl( @@ -53,7 +53,7 @@ pub async fn start_test_indexer( reader_writer_config, // reset_database false, - Some(data_ingestion_path), + data_ingestion_path, CancellationToken::new(), new_database, ) @@ -86,11 +86,14 @@ pub async fn start_test_indexer_impl( let mut config = IndexerConfig { db_url: Some(db_url.clone().into()), + // As fallback sync mechanism enable Rest Api if `data_ingestion_path` was not provided + remote_store_url: data_ingestion_path + .is_none() + .then_some(format!("{rpc_url}/api/v1")), rpc_client_url: rpc_url, reset_db: true, fullnode_sync_worker: true, rpc_server_worker: false, - remote_store_url: None, data_ingestion_path, ..Default::default() }; diff --git a/crates/iota-indexer/tests/common/mod.rs b/crates/iota-indexer/tests/common/mod.rs index 55273b8a1d9..23ccf354899 100644 --- a/crates/iota-indexer/tests/common/mod.rs +++ b/crates/iota-indexer/tests/common/mod.rs @@ -114,7 +114,7 @@ pub async fn start_test_cluster_with_read_write_indexer( builder_modifier: Option TestClusterBuilder>>, ) -> (TestCluster, PgIndexerStore, HttpClient) { let temp = tempdir().unwrap().into_path(); - let mut builder = TestClusterBuilder::new().with_data_ingestion_dir(temp.clone()); + let mut builder = TestClusterBuilder::new(); if let Some(builder_modifier) = builder_modifier { builder = builder_modifier(builder); @@ -127,7 +127,7 @@ pub async fn start_test_cluster_with_read_write_indexer( Some(get_indexer_db_url(None)), cluster.rpc_url().to_string(), ReaderWriterConfig::writer_mode(None), - temp.clone(), + None, database_name, ) .await; @@ -305,7 +305,7 @@ pub async fn start_simulacrum_rest_api_with_write_indexer( Some(get_indexer_db_url(None)), format!("http://{}", server_url), ReaderWriterConfig::writer_mode(None), - data_ingestion_path, + Some(data_ingestion_path), database_name, ) .await; diff --git a/crates/iota-indexer/tests/rpc-tests/read_api.rs b/crates/iota-indexer/tests/rpc-tests/read_api.rs index 5d0d17f7e05..382c6ea4ad3 100644 --- a/crates/iota-indexer/tests/rpc-tests/read_api.rs +++ b/crates/iota-indexer/tests/rpc-tests/read_api.rs @@ -1158,6 +1158,7 @@ fn get_total_transaction_blocks() { runtime.block_on(async move { indexer_wait_for_checkpoint(store, checkpoint).await; + let total_transaction_blocks = client.get_total_transaction_blocks().await.unwrap(); let fullnode_checkpoint = cluster diff --git a/crates/iota/src/iota_commands.rs b/crates/iota/src/iota_commands.rs index 0e37b2f016b..b4eb64d0724 100644 --- a/crates/iota/src/iota_commands.rs +++ b/crates/iota/src/iota_commands.rs @@ -755,7 +755,7 @@ async fn start( Some(pg_address.clone()), fullnode_url.clone(), ReaderWriterConfig::writer_mode(None), - data_ingestion_path.clone(), + Some(data_ingestion_path.clone()), None, ) .await; @@ -766,7 +766,7 @@ async fn start( Some(pg_address.clone()), fullnode_url.clone(), ReaderWriterConfig::reader_mode(indexer_address.to_string()), - data_ingestion_path, + Some(data_ingestion_path), None, ) .await;