diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dafd398a..045a5c26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -193,7 +193,7 @@ jobs: env: RISC0_DEV_MODE: "1" RUST_LOG: "debug" - run: cargo nextest run -p integration_tests indexer --test-threads=1 + run: cargo nextest run -p integration_tests indexer -- indexer_test_run - name: Debug Docker state on failure if: failure() diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index ecebe38f..d7b30838 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -187,11 +187,14 @@ impl TestContext { let addr = SocketAddr::from(([127, 0, 0, 1], port)); - // Wait for Bedrock consensus to stabilize after startup - // The cfgsync server coordinates all 4 nodes; we give them time to reach consensus - debug!("Bedrock services are up, waiting for consensus stabilization..."); - tokio::time::sleep(std::time::Duration::from_secs(5)).await; - debug!("Bedrock consensus stabilization complete"); + // Wait for Bedrock consensus to stabilize and finalization to begin + // The cfgsync server coordinates all 4 nodes; finalization requires multiple rounds + // Extended timeout to ensure blocks can achieve finalized status + info!( + "Bedrock services are up at {addr}, waiting for consensus stabilization and finalization..." + ); + tokio::time::sleep(std::time::Duration::from_secs(30)).await; + info!("Bedrock stabilization complete, proceeding with test"); Ok((compose, addr)) } diff --git a/integration_tests/tests/indexer.rs b/integration_tests/tests/indexer.rs index 826e6c97..0918f0a3 100644 --- a/integration_tests/tests/indexer.rs +++ b/integration_tests/tests/indexer.rs @@ -19,18 +19,41 @@ const L2_TO_L1_TIMEOUT_MILLIS: u64 = 600_000; async fn indexer_test_run() -> Result<()> { let ctx = TestContext::new().await?; - // RUN OBSERVATION - info!( - "Waiting {} ms for blocks to be created and finalized on Bedrock", - L2_TO_L1_TIMEOUT_MILLIS - ); - tokio::time::sleep(std::time::Duration::from_millis(L2_TO_L1_TIMEOUT_MILLIS)).await; - info!("Wait period complete"); + info!("TestContext initialized, Bedrock + Sequencer + Indexer all running"); + + // Check finalization progress over time to diagnose stalls + for i in 0..6 { + let elapsed_secs = (i * 100) as u64; + if i > 0 { + info!( + "Waiting {} more seconds for blocks to finalize...", + elapsed_secs + ); + tokio::time::sleep(std::time::Duration::from_secs(elapsed_secs)).await; + } + + let seq_block = + sequencer_service_rpc::RpcClient::get_last_block_id(ctx.sequencer_client()).await?; + let indexer_block = ctx + .indexer_client() + .get_last_finalized_block_id() + .await + .unwrap(); + + info!( + "Status at +{elapsed_secs}s: sequencer at {seq_block}, indexer finalized at {indexer_block}" + ); + + if indexer_block > 1 { + info!("Finalization starting, breaking early"); + break; + } + } let last_block_seq = sequencer_service_rpc::RpcClient::get_last_block_id(ctx.sequencer_client()).await?; - info!("Last block on sequencer: {last_block_seq}"); + info!("Final: Sequencer at block {last_block_seq}"); let last_block_indexer = ctx .indexer_client() @@ -38,7 +61,7 @@ async fn indexer_test_run() -> Result<()> { .await .unwrap(); - info!("Last finalized block on indexer: {last_block_indexer}"); + info!("Final: Indexer finalized at block {last_block_indexer}"); assert!(last_block_indexer > 1);