diff --git a/sync/src/relayer/tests/compact_block_process.rs b/sync/src/relayer/tests/compact_block_process.rs index df4e7491d4..3473b8e405 100644 --- a/sync/src/relayer/tests/compact_block_process.rs +++ b/sync/src/relayer/tests/compact_block_process.rs @@ -200,6 +200,21 @@ fn test_accept_not_a_better_block() { peer_index, ); assert_eq!(compact_block_process.execute(), Status::ok()); + + // wait chain_service processed the compact block, check block hash in snapshot + { + let now = std::time::Instant::now(); + loop { + std::thread::sleep(std::time::Duration::from_millis(100)); + if now.elapsed().as_secs() > 5 { + panic!("wait chain_service processed the compact block timeout"); + } + let snapshot = relayer.shared.shared().snapshot(); + if snapshot.get_block(&uncle_block.header().hash()).is_some() { + break; + } + } + } } #[test] diff --git a/sync/src/tests/synchronizer/functions.rs b/sync/src/tests/synchronizer/functions.rs index a0c758c695..a63937d727 100644 --- a/sync/src/tests/synchronizer/functions.rs +++ b/sync/src/tests/synchronizer/functions.rs @@ -51,6 +51,10 @@ fn start_chain(consensus: Option) -> (ChainController, Shared, Synchr let chain_controller = start_chain_services(pack.take_chain_services_builder()); + while chain_controller.is_verifying_unverified_blocks_on_startup() { + std::thread::sleep(std::time::Duration::from_millis(10)); + } + let sync_shared = Arc::new(SyncShared::new( shared.clone(), Default::default(),