Skip to content

Commit

Permalink
Improve test_accept_not_a_better_block wait chain_service finished be…
Browse files Browse the repository at this point in the history
…fore exit

Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Aug 2, 2024
1 parent b31c07d commit 5b895f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sync/src/relayer/tests/compact_block_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions sync/src/tests/synchronizer/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ fn start_chain(consensus: Option<Consensus>) -> (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(),
Expand Down

0 comments on commit 5b895f2

Please sign in to comment.