Skip to content

Commit f55eae9

Browse files
authored
Merge pull request #850 from input-output-hk/feature/etcm_269_healthcheck_bugfix
[ETCM-269] Add missing runToFuture to healthcheck endpoint
2 parents c515e36 + 22500a7 commit f55eae9

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/main/scala/io/iohk/ethereum/jsonrpc/server/http/JsonRpcHttpServer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ trait JsonRpcHttpServer extends Json4sSupport with RateLimit with Logger {
103103
entity = HttpEntity(ContentTypes.`application/json`, serialization.writePretty(response))
104104
)
105105
}
106-
complete(httpResponseF)
106+
complete(httpResponseF.runToFuture)
107107
}
108108

109109
private def handleRequest(request: JsonRpcRequest) = {

src/test/scala/io/iohk/ethereum/jsonrpc/server/http/JsonRpcHttpServerSpec.scala

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package io.iohk.ethereum.jsonrpc.server.http
33
import java.net.InetAddress
44
import java.time.{Clock, Instant, ZoneId}
55
import java.util.concurrent.TimeUnit
6-
76
import akka.actor.ActorSystem
87
import akka.http.scaladsl.model._
98
import akka.http.scaladsl.model.headers.{HttpOrigin, Origin}
@@ -19,13 +18,33 @@ import org.scalamock.scalatest.MockFactory
1918
import org.scalatest.flatspec.AnyFlatSpec
2019
import org.scalatest.matchers.should.Matchers
2120
import akka.http.scaladsl.model.headers._
21+
import io.iohk.ethereum.healthcheck.{HealthcheckResponse, HealthcheckResult}
2222
import io.iohk.ethereum.utils.Logger
2323
import io.iohk.ethereum.jsonrpc.server.controllers.JsonRpcBaseController
24-
2524
import scala.concurrent.duration.FiniteDuration
2625

2726
class JsonRpcHttpServerSpec extends AnyFlatSpec with Matchers with ScalatestRouteTest {
2827

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+
2948
it should "pass valid json request to controller" in new TestSetup {
3049
(mockJsonRpcController.handleRequest _)
3150
.expects(*)

0 commit comments

Comments
 (0)