Skip to content

Commit 9181148

Browse files
committed
test: add test for connection info
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 4bac006 commit 9181148

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

crates/service/tests/router_test.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use std::time::Duration;
4+
use std::{net::SocketAddr, time::Duration};
55

66
use alloy::primitives::Address;
7-
use axum::{body::to_bytes, http::Request};
7+
use axum::{body::to_bytes, extract::ConnectInfo, http::Request, Extension};
88
use axum_extra::headers::Header;
99
use indexer_config::{BlockchainConfig, GraphNodeConfig, IndexerConfig, NonZeroGRT};
1010
use indexer_monitor::EscrowAccounts;
@@ -95,7 +95,20 @@ async fn full_integration_test(database: PgPool) {
9595
.allocations(allocations)
9696
.build();
9797

98-
let mut app = router.create_router().await.unwrap();
98+
let socket_info = Extension(ConnectInfo(SocketAddr::from(([0, 0, 0, 0], 1337))));
99+
let mut app = router.create_router().await.unwrap().layer(socket_info);
100+
101+
let res = app
102+
.call(Request::get("/").body(String::new()).unwrap())
103+
.await
104+
.unwrap();
105+
106+
assert_eq!(res.status(), StatusCode::OK);
107+
108+
let graphql_response = res.into_body();
109+
let bytes = to_bytes(graphql_response, usize::MAX).await.unwrap();
110+
let res = String::from_utf8(bytes.into()).unwrap();
111+
insta::assert_snapshot!(res);
99112

100113
let receipt = create_signed_receipt(
101114
SignedReceiptRequest::builder()

crates/service/tests/snapshots/router_test__full_integration_test-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ source: crates/service/tests/router_test.rs
33
expression: res
44
snapshot_kind: text
55
---
6-
{"message":"No Tap receipt was found in the request"}
6+
{"graphQLResponse":"\n {\n \"data\": {\n \"graphNetwork\": {\n \"currentEpoch\": 960\n }\n }\n }\n ","attestation":null}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
source: crates/service/tests/router_test.rs
3+
expression: res
4+
snapshot_kind: text
5+
---
6+
{"message":"No Tap receipt was found in the request"}

crates/service/tests/snapshots/router_test__full_integration_test.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ source: crates/service/tests/router_test.rs
33
expression: res
44
snapshot_kind: text
55
---
6-
{"graphQLResponse":"\n {\n \"data\": {\n \"graphNetwork\": {\n \"currentEpoch\": 960\n }\n }\n }\n ","attestation":null}
6+
Service is up and running

0 commit comments

Comments
 (0)