@@ -4,12 +4,14 @@ mod tests {
44
55 use axum:: body:: { to_bytes, Body } ;
66 use axum:: http:: Request ;
7+ use blockfrost_platform:: api:: root:: RootResponse ;
78 use blockfrost_platform:: {
89 cli:: { Config , LogLevel , Mode , Network } ,
910 server:: build,
1011 } ;
1112 use lazy_static:: lazy_static;
12- use serde_json:: Value ;
13+ use pretty_assertions:: assert_eq;
14+ use reqwest:: StatusCode ;
1315 use tower:: ServiceExt ;
1416
1517 lazy_static ! {
@@ -27,12 +29,12 @@ mod tests {
2729 server_address : "0.0.0.0" . into ( ) ,
2830 server_port : 8080 ,
2931 log_level : LogLevel :: Info . into ( ) ,
30- network_magic : 1 ,
31- mode : Mode :: Full ,
32+ network_magic : 2 ,
33+ mode : Mode :: Compact ,
3234 node_socket_path : "/run/cardano-node/node.socket" . into ( ) ,
3335 icebreakers_config : None ,
3436 max_pool_connections : 10 ,
35- network : Network :: Preprod ,
37+ network : Network :: Preview ,
3638 }
3739 }
3840
@@ -51,25 +53,29 @@ mod tests {
5153 . await
5254 . expect ( "Failed to send request" ) ;
5355
54- println ! ( "response:{:?}" , response. body( ) ) ;
55-
56- // assert_eq!(
57- // response.status(),
58- // StatusCode::OK,
59- // "Root route should return 200"
60- // );
56+ // Root route should return 200
57+ assert_eq ! (
58+ response. status( ) ,
59+ StatusCode :: OK ,
60+ "Root route should return 200"
61+ ) ;
6162
6263 let body_bytes = to_bytes ( response. into_body ( ) , usize:: MAX )
6364 . await
6465 . expect ( "Failed to read response body" ) ;
6566
66- let json_body: Value =
67- serde_json:: from_slice ( & body_bytes) . expect ( "Response body is not valid JSON" ) ;
68-
69- let body_text = String :: from_utf8_lossy ( & body_bytes) ;
67+ let root_response: RootResponse = serde_json:: from_slice ( & body_bytes)
68+ . expect ( "Response body is not valid JSON or doesn't match RootResponse" ) ;
7069
71- println ! ( "body_text:{:?}" , body_text) ;
70+ // Root data
71+ assert ! (
72+ root_response. errors. is_empty( ) ,
73+ "Expected no errors in the response"
74+ ) ;
75+ assert_eq ! ( root_response. name, "blockfrost-platform" ) ;
76+ assert ! ( root_response. healthy) ;
7277
73- assert_eq ! ( json_body[ "name" ] , "blockfrost-platform" ) ;
78+ // Node should be 100% synced
79+ assert_eq ! ( root_response. sync_progress. percentage, 100.00 ) ;
7480 }
7581}
0 commit comments