@@ -3,7 +3,6 @@ package io.iohk.ethereum.jsonrpc.server.http
3
3
import java .net .InetAddress
4
4
import java .time .{Clock , Instant , ZoneId }
5
5
import java .util .concurrent .TimeUnit
6
-
7
6
import akka .actor .ActorSystem
8
7
import akka .http .scaladsl .model ._
9
8
import akka .http .scaladsl .model .headers .{HttpOrigin , Origin }
@@ -19,13 +18,33 @@ import org.scalamock.scalatest.MockFactory
19
18
import org .scalatest .flatspec .AnyFlatSpec
20
19
import org .scalatest .matchers .should .Matchers
21
20
import akka .http .scaladsl .model .headers ._
21
+ import io .iohk .ethereum .healthcheck .{HealthcheckResponse , HealthcheckResult }
22
22
import io .iohk .ethereum .utils .Logger
23
23
import io .iohk .ethereum .jsonrpc .server .controllers .JsonRpcBaseController
24
-
25
24
import scala .concurrent .duration .FiniteDuration
26
25
27
26
class JsonRpcHttpServerSpec extends AnyFlatSpec with Matchers with ScalatestRouteTest {
28
27
28
+ it should " respond to healthcheck" in new TestSetup {
29
+ (mockJsonRpcHealthChecker.healthCheck _)
30
+ .expects()
31
+ .returning(Task .now(HealthcheckResponse (List (HealthcheckResult (" listening" , " OK" , None )))))
32
+
33
+ val getRequest = HttpRequest (HttpMethods .GET , uri = " /healthcheck" )
34
+
35
+ getRequest ~> Route .seal(mockJsonRpcHttpServer.route) ~> check {
36
+ status shouldEqual StatusCodes .OK
37
+ responseAs[String ] shouldEqual """ {
38
+ | "checks":[
39
+ | {
40
+ | "description":"listening",
41
+ | "status":"OK"
42
+ | }
43
+ | ]
44
+ |}""" .stripMargin
45
+ }
46
+ }
47
+
29
48
it should " pass valid json request to controller" in new TestSetup {
30
49
(mockJsonRpcController.handleRequest _)
31
50
.expects(* )
0 commit comments