Skip to content

Commit

Permalink
add integration test to test pool shutdown functionality as pool has …
Browse files Browse the repository at this point in the history
…hard dependence on template provider
  • Loading branch information
Shourya742 committed Jan 22, 2025
1 parent 44520d8 commit 91ea198
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions roles/tests-integration/tests/pool_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,25 @@ async fn header_timestamp_value_assertion_in_new_extended_mining_job() {
"The `minntime` field of the second NewExtendedMiningJob does not match the `header_timestamp`!"
);
}


/// Validates the graceful shutdown behavior of the pool.
///
/// This test performs the following steps:
/// 1. Starts a Template Provider (`_tp`) and retrieves its address.
/// 2. Starts a Pool, providing the Template Provider's address if available.
/// 3. Invokes the `shutdown` API on the Pool to initiate a graceful shutdown.
/// 4. Waits briefly to allow the shutdown process to complete.
/// 5. Verifies that the Pool's address is available for reuse, indicating a proper shutdown.
///
/// The test ensures that the Pool cleans up its resources properly and shuts down
/// without leaving the address in use.
#[tokio::test]
async fn check_if_pool_shutsdown_gracefully() {
let (_tp, tp_addr) = start_template_provider(None).await;
let (pool, pool_addr) = start_pool(Some(tp_addr)).await;
pool.shutdown();
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
dbg!(pool_addr);
assert!(tokio::net::TcpListener::bind(pool_addr).await.is_ok());
}

0 comments on commit 91ea198

Please sign in to comment.