|
1 | 1 | use std::net::{IpAddr, Ipv4Addr}; |
2 | 2 |
|
3 | 3 | use async_trait::async_trait; |
4 | | -use axum::body::{Body, Bytes, HttpBody}; |
| 4 | +use axum::body::Body; |
5 | 5 | use axum::http::{Request, StatusCode}; |
6 | | -use axum::response::Response; |
7 | | -use axum::Router; |
8 | 6 | use pretty_assertions::assert_eq; |
9 | 7 | use serde::{Deserialize, Serialize}; |
10 | 8 | use starknet_api::block::{BlockHeader, BlockNumber}; |
11 | 9 | use tower::ServiceExt; |
12 | 10 |
|
13 | 11 | use crate::header::{HeaderStorageReader, HeaderStorageWriter}; |
14 | 12 | use crate::storage_reader_server::{ServerConfig, StorageReaderServer, StorageReaderServerHandler}; |
| 13 | +use crate::storage_reader_server_test_utils::{send_storage_query, to_bytes}; |
15 | 14 | use crate::test_utils::get_test_storage; |
16 | 15 | use crate::{StorageError, StorageReader}; |
17 | 16 |
|
@@ -109,19 +108,6 @@ async fn test_endpoint_query_nonexistent_block() { |
109 | 108 | assert!(!test_response.found); |
110 | 109 | } |
111 | 110 |
|
112 | | -async fn send_storage_query<T: Serialize>(app: Router, request: &T) -> Response { |
113 | | - app.oneshot( |
114 | | - Request::builder() |
115 | | - .method("POST") |
116 | | - .uri("/storage/query") |
117 | | - .header("content-type", "application/json") |
118 | | - .body(Body::from(serde_json::to_string(request).unwrap())) |
119 | | - .unwrap(), |
120 | | - ) |
121 | | - .await |
122 | | - .unwrap() |
123 | | -} |
124 | | - |
125 | 111 | #[tokio::test] |
126 | 112 | async fn test_endpoint_handler_error() { |
127 | 113 | let ((reader, _writer), _temp_dir) = get_test_storage(); |
@@ -169,8 +155,3 @@ async fn test_endpoint_invalid_json() { |
169 | 155 | // Should return error status code |
170 | 156 | assert!(!response.status().is_success()); |
171 | 157 | } |
172 | | - |
173 | | -// Helper function to convert response body to bytes |
174 | | -async fn to_bytes(res: Response) -> Bytes { |
175 | | - res.into_body().collect().await.unwrap().to_bytes() |
176 | | -} |
0 commit comments