Adds timeouts tonic clients in tests (#8724)
This commit is contained in:
parent
4f6c4aeaa1
commit
14f473d1ea
|
@ -232,7 +232,9 @@ async fn start_server_and_get_client() -> (
|
||||||
MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
MockService<ScanRequest, ScanResponse, PanicAssertion>,
|
||||||
) {
|
) {
|
||||||
// get a mocked scan service
|
// 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
|
// start the gRPC server
|
||||||
let listen_addr: std::net::SocketAddr = "127.0.0.1:0"
|
let listen_addr: std::net::SocketAddr = "127.0.0.1:0"
|
||||||
|
@ -246,8 +248,12 @@ async fn start_server_and_get_client() -> (
|
||||||
// wait for the server to start
|
// wait for the server to start
|
||||||
sleep(Duration::from_secs(1));
|
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
|
// connect to the gRPC server
|
||||||
let client = ScannerClient::connect(format!("http://{listen_addr}"))
|
let client = ScannerClient::connect(endpoint)
|
||||||
.await
|
.await
|
||||||
.expect("server should receive connection");
|
.expect("server should receive connection");
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,10 @@ async fn start_server_and_get_client() -> Result<(
|
||||||
.parse()
|
.parse()
|
||||||
.expect("hard-coded IP and u16 port should parse successfully");
|
.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 (mock_chain_tip_change, mock_chain_tip_change_sender) = MockChainTip::new();
|
||||||
|
|
||||||
let (server_task, listen_addr) =
|
let (server_task, listen_addr) =
|
||||||
|
@ -67,8 +70,12 @@ async fn start_server_and_get_client() -> Result<(
|
||||||
// wait for the server to start
|
// wait for the server to start
|
||||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
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
|
// connect to the gRPC server
|
||||||
let client = IndexerClient::connect(format!("http://{listen_addr}"))
|
let client = IndexerClient::connect(endpoint)
|
||||||
.await
|
.await
|
||||||
.expect("server should receive connection");
|
.expect("server should receive connection");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue