Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman committed Sep 15, 2023
1 parent 4f02ed5 commit 61f4850
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/fuel-indexer-tests/tests/web_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ async fn test_replacing_an_indexer_and_keeping_or_removing_data() {
let mut conn =
IndexerConnection::Postgres(Box::new(db.pool.acquire().await.unwrap()));

// Allow the indexer to start and process blocks.
tokio::time::sleep(std::time::Duration::from_secs(2)).await;

let last = last_block_height_for_indexer(
&mut conn,
manifest.namespace(),
Expand Down Expand Up @@ -359,6 +362,9 @@ async fn test_replacing_an_indexer_and_keeping_or_removing_data() {
.await
.unwrap();

// Allow the old indexer to shut down and the new indexer to start.
tokio::time::sleep(std::time::Duration::from_secs(2)).await;

let last = last_block_height_for_indexer(
&mut conn,
manifest.namespace(),
Expand Down Expand Up @@ -386,8 +392,8 @@ async fn test_replacing_an_indexer_and_keeping_or_removing_data() {
.unwrap();

// We removed the data, and the new indexer sould not start until block 5 is
// present. The last block must be 1.
assert_eq!(last, 1);
// present. The last block must be 0.
assert_eq!(last, 0);

// Increase blocks to 5. The new indexer should start.
mock_request("/block").await;
Expand Down
4 changes: 4 additions & 0 deletions packages/fuel-indexer/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ impl IndexerService {
mut manifest: Manifest,
remove_data: bool,
) -> IndexerResult<()> {
if let Some(killer) = self.killers.get(&manifest.uid()) {
killer.store(true, std::sync::atomic::Ordering::SeqCst);
}

let mut conn = self.pool.acquire().await?;

let indexer_exists = (queries::get_indexer_id(
Expand Down

0 comments on commit 61f4850

Please sign in to comment.