Skip to content

Commit 9da36a2

Browse files
authored
Merge branch 'develop' into release-v3.2.1-merge-back
2 parents a34af78 + f55eae9 commit 9da36a2

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
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/blockchain/sync/regular/BlockFetcherSpec.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import akka.actor.ActorSystem
66
import akka.testkit.{TestKit, TestProbe}
77
import com.miguno.akka.testing.VirtualTime
88
import io.iohk.ethereum.Mocks.{MockValidatorsAlwaysSucceed, MockValidatorsFailingOnBlockBodies}
9-
import io.iohk.ethereum.{BlockHelpers, Timeouts}
9+
import io.iohk.ethereum.{BlockHelpers, Timeouts, WithActorSystemShutDown}
1010
import io.iohk.ethereum.Fixtures.{Blocks => FixtureBlocks}
1111
import io.iohk.ethereum.blockchain.sync.PeersClient.BlacklistPeer
1212
import io.iohk.ethereum.blockchain.sync.regular.BlockFetcher.{InternalLastBlockImport, InvalidateBlocksFrom, PickBlocks}
@@ -24,7 +24,11 @@ import org.scalatest.matchers.should.Matchers
2424

2525
import scala.concurrent.duration._
2626

27-
class BlockFetcherSpec extends TestKit(ActorSystem("BlockFetcherSpec_System")) with AnyFreeSpecLike with Matchers {
27+
class BlockFetcherSpec
28+
extends TestKit(ActorSystem("BlockFetcherSpec_System"))
29+
with AnyFreeSpecLike
30+
with WithActorSystemShutDown
31+
with Matchers {
2832

2933
"BlockFetcher" - {
3034

src/test/scala/io/iohk/ethereum/blockchain/sync/regular/BlockFetcherStateSpec.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ package io.iohk.ethereum.blockchain.sync.regular
33
import akka.actor.ActorSystem
44
import akka.testkit.{TestKit, TestProbe}
55
import io.iohk.ethereum.Mocks.MockValidatorsAlwaysSucceed
6-
import io.iohk.ethereum.BlockHelpers
6+
import io.iohk.ethereum.{BlockHelpers, WithActorSystemShutDown}
77
import io.iohk.ethereum.network.PeerId
88
import org.scalatest.matchers.should.Matchers
99
import org.scalatest.wordspec.AnyWordSpecLike
1010

1111
import scala.collection.immutable.Queue
1212

13-
class BlockFetcherStateSpec extends TestKit(ActorSystem()) with AnyWordSpecLike with Matchers {
13+
class BlockFetcherStateSpec
14+
extends TestKit(ActorSystem("BlockFetcherStateSpec_System"))
15+
with AnyWordSpecLike
16+
with WithActorSystemShutDown
17+
with Matchers {
1418

1519
lazy val validators = new MockValidatorsAlwaysSucceed
1620

src/test/scala/io/iohk/ethereum/consensus/ethash/EthashMinerSpec.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package ethash
33

44
import akka.actor.{ActorRef, ActorSystem}
55
import akka.testkit.{TestActor, TestActorRef, TestKit, TestProbe}
6-
import io.iohk.ethereum.Fixtures
6+
import io.iohk.ethereum.{Fixtures, WithActorSystemShutDown}
77
import io.iohk.ethereum.consensus.blocks.{PendingBlock, PendingBlockAndState}
88
import io.iohk.ethereum.consensus.ethash.validators.EthashBlockHeaderValidator
99
import io.iohk.ethereum.consensus.validators.BlockHeaderValid
@@ -16,11 +16,17 @@ import monix.eval.Task
1616
import org.bouncycastle.util.encoders.Hex
1717
import org.scalamock.scalatest.MockFactory
1818
import org.scalatest.Tag
19+
1920
import scala.concurrent.duration._
2021
import org.scalatest.flatspec.AnyFlatSpecLike
2122
import org.scalatest.matchers.should.Matchers
2223

23-
class EthashMinerSpec extends TestKit(ActorSystem("EthashMinerSpec_System")) with AnyFlatSpecLike with Matchers {
24+
class EthashMinerSpec
25+
extends TestKit(ActorSystem("EthashMinerSpec_System"))
26+
with AnyFlatSpecLike
27+
with WithActorSystemShutDown
28+
with Matchers {
29+
2430
final val EthashMinerSpecTag = Tag("EthashMinerSpec")
2531

2632
private implicit val timeout: Duration = 10.minutes

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(*)

src/test/scala/io/iohk/ethereum/network/PeerManagerSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import io.iohk.ethereum.network.p2p.messages.CommonMessages.NewBlock
1818
import io.iohk.ethereum.network.p2p.messages.ProtocolVersions
1919
import io.iohk.ethereum.network.p2p.messages.WireProtocol.Disconnect
2020
import io.iohk.ethereum.utils.Config
21-
import io.iohk.ethereum.{Fixtures, NormalPatience}
21+
import io.iohk.ethereum.{Fixtures, NormalPatience, WithActorSystemShutDown}
2222
import org.bouncycastle.util.encoders.Hex
2323
import org.scalatest.concurrent.Eventually
2424
import org.scalatest.flatspec.AnyFlatSpecLike
@@ -28,6 +28,7 @@ import org.scalatest.matchers.should.Matchers
2828
class PeerManagerSpec
2929
extends TestKit(ActorSystem("PeerManagerSpec_System"))
3030
with AnyFlatSpecLike
31+
with WithActorSystemShutDown
3132
with Matchers
3233
with Eventually
3334
with NormalPatience {

src/test/scala/io/iohk/ethereum/network/discovery/PeerDiscoveryManagerSpec.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package io.iohk.ethereum.network.discovery
22

3-
import akka.pattern.ask
43
import akka.actor.ActorSystem
4+
import akka.pattern.{AskTimeoutException, ask}
55
import akka.testkit.{TestActorRef, TestKit}
66
import akka.util.{ByteString, Timeout}
77
import cats.effect.Resource
8-
import io.iohk.ethereum.NormalPatience
9-
import io.iohk.ethereum.utils.Config
108
import io.iohk.ethereum.db.storage.KnownNodesStorage
9+
import io.iohk.ethereum.utils.Config
10+
import io.iohk.ethereum.{NormalPatience, WithActorSystemShutDown}
1111
import io.iohk.scalanet.discovery.crypto.PublicKey
1212
import io.iohk.scalanet.discovery.ethereum.v4.DiscoveryService
1313
import io.iohk.scalanet.discovery.ethereum.{Node => ENode}
1414
import monix.eval.Task
1515
import monix.execution.Scheduler
1616
import monix.execution.atomic.AtomicInt
17-
import org.scalatest.concurrent.Eventually
17+
import org.scalamock.scalatest.MockFactory
18+
import org.scalatest.concurrent.{Eventually, ScalaFutures}
1819
import org.scalatest.flatspec.AnyFlatSpecLike
1920
import org.scalatest.matchers.should.Matchers
20-
import org.scalatest.concurrent.ScalaFutures
21-
import org.scalamock.scalatest.MockFactory
22-
import scala.concurrent.duration._
2321
import scodec.bits.BitVector
24-
import scala.util.control.NoStackTrace
22+
2523
import scala.collection.immutable.SortedSet
26-
import akka.pattern.AskTimeoutException
24+
import scala.concurrent.duration._
25+
import scala.util.control.NoStackTrace
2726

2827
class PeerDiscoveryManagerSpec
2928
extends TestKit(ActorSystem("PeerDiscoveryManagerSpec_System"))
3029
with AnyFlatSpecLike
30+
with WithActorSystemShutDown
3131
with Matchers
3232
with Eventually
3333
with MockFactory

0 commit comments

Comments
 (0)