Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(tests): Adds timeouts tonic clients in tests #8724

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions zebra-grpc/src/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ async fn start_server_and_get_client() -> (
MockService<ScanRequest, ScanResponse, PanicAssertion>,
) {
// get a mocked scan service
let mock_scan_service = MockService::build().for_unit_tests();
let mock_scan_service = MockService::build()
.with_max_request_delay(Duration::from_secs(2))
.for_unit_tests();

// start the gRPC server
let listen_addr: std::net::SocketAddr = "127.0.0.1:0"
Expand All @@ -246,8 +248,12 @@ async fn start_server_and_get_client() -> (
// wait for the server to start
sleep(Duration::from_secs(1));

let endpoint = tonic::transport::channel::Endpoint::new(format!("http://{listen_addr}"))
.unwrap()
.timeout(Duration::from_secs(2));

// connect to the gRPC server
let client = ScannerClient::connect(format!("http://{listen_addr}"))
let client = ScannerClient::connect(endpoint)
.await
.expect("server should receive connection");

Expand Down
11 changes: 9 additions & 2 deletions zebra-rpc/src/indexer/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ async fn start_server_and_get_client() -> Result<(
.parse()
.expect("hard-coded IP and u16 port should parse successfully");

let mock_read_service = MockService::build().for_unit_tests();
let mock_read_service = MockService::build()
.with_max_request_delay(Duration::from_secs(2))
.for_unit_tests();

let (mock_chain_tip_change, mock_chain_tip_change_sender) = MockChainTip::new();

let (server_task, listen_addr) =
Expand All @@ -67,8 +70,12 @@ async fn start_server_and_get_client() -> Result<(
// wait for the server to start
tokio::time::sleep(Duration::from_secs(1)).await;

let endpoint = tonic::transport::channel::Endpoint::new(format!("http://{listen_addr}"))
.unwrap()
.timeout(Duration::from_secs(2));

// connect to the gRPC server
let client = IndexerClient::connect(format!("http://{listen_addr}"))
let client = IndexerClient::connect(endpoint)
.await
.expect("server should receive connection");

Expand Down
Loading