openzeppelin_monitor/utils/tests/
http.rs

1use reqwest::Client;
2use reqwest_middleware::ClientWithMiddleware;
3use reqwest_retry::DefaultRetryableStrategy;
4use std::sync::Arc;
5
6use crate::{
7	services::notification::NotificationClientPool,
8	utils::{create_retryable_http_client, HttpRetryConfig},
9};
10
11/// Creates a default HTTP client with retry capabilities for testing purposes.
12pub fn create_test_http_client() -> Arc<ClientWithMiddleware> {
13	let retryable_client = create_retryable_http_client::<DefaultRetryableStrategy>(
14		&HttpRetryConfig::default(),
15		Client::new(),
16		None,
17	);
18
19	Arc::new(retryable_client)
20}
21
22/// Creates a test HTTP client from the notification client pool.
23/// Currently used for integration tests
24pub async fn get_http_client_from_notification_pool() -> Arc<ClientWithMiddleware> {
25	let pool = NotificationClientPool::new();
26	let retry_policy = HttpRetryConfig::default();
27	let http_client = pool.get_or_create_http_client(&retry_policy).await;
28	http_client.unwrap()
29}