Skip to content

Commit

Permalink
[ETCM-126] fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lemastero committed Oct 26, 2020
1 parent a605089 commit 90f7761
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/main/scala/io/iohk/ethereum/jsonrpc/AkkaTaskOps.scala
Expand Up @@ -4,14 +4,17 @@ import akka.actor.{Actor, ActorRef}
import akka.util.Timeout
import monix.eval.Task

import scala.reflect.ClassTag

object AkkaTaskOps { self: ActorRef =>
implicit class TaskActorOps(to: ActorRef) {
import akka.pattern.ask

def askFor[A](message: Any)(implicit timeout: Timeout, sender: ActorRef = Actor.noSender): Task[A] =
def askFor[A](
message: Any
)(implicit timeout: Timeout, classTag: ClassTag[A], sender: ActorRef = Actor.noSender): Task[A] =
Task
.fromFuture(to ? message)
.fromFuture((to ? message).mapTo[A])
.timeout(timeout.duration)
.map(_.asInstanceOf[A])
}
}
2 changes: 1 addition & 1 deletion src/main/scala/io/iohk/ethereum/jsonrpc/EthService.scala
Expand Up @@ -541,7 +541,7 @@ class EthService(

val bestBlock = blockchain.getBestBlock()
val response: ServiceResponse[GetWorkResponse] =
Task.zip(getOmmersFromPool(bestBlock.hash), getTransactionsFromPool).map { case (ommers, pendingTxs) =>
Task.parZip2(getOmmersFromPool(bestBlock.hash), getTransactionsFromPool()).map { case (ommers, pendingTxs) =>
val blockGenerator = ethash.blockGenerator
val pb = blockGenerator.generateBlock(
bestBlock,
Expand Down
Expand Up @@ -406,7 +406,9 @@ class BlockGeneratorSpec extends AnyFlatSpec with Matchers with ScalaCheckProper
val fullBlock = pendingBlock.block.copy(header =
pendingBlock.block.header.copy(nonce = minedNonce, mixHash = minedMixHash, unixTimestamp = miningTimestamp)
)
validators.blockHeaderValidator.validate(fullBlock.header, blockchain.getBlockHeaderByHash) shouldBe Right(BlockHeaderValid)
validators.blockHeaderValidator.validate(fullBlock.header, blockchain.getBlockHeaderByHash) shouldBe Right(
BlockHeaderValid
)
blockExecution.executeBlock(fullBlock) shouldBe a[Right[_, Seq[Receipt]]]
fullBlock.body.transactionList shouldBe Seq(signedTransaction.tx)
fullBlock.header.extraData shouldBe headerExtraData
Expand Down
Expand Up @@ -225,7 +225,7 @@ class BlockWithCheckpointHeaderValidatorSpec
val duplicatedSigner = ByteString(crypto.pubKeyFromKeyPair(keys.head))
val expectedSigners =
(keys.map(kp => ByteString(crypto.pubKeyFromKeyPair(kp))) :+ duplicatedSigner)
.sortBy(_.toSeq)
.sortBy(_.toSeq)
actualSigners shouldEqual expectedSigners

val headerWithInvalidCheckpoint = checkpointBlockGenerator
Expand All @@ -247,7 +247,8 @@ class BlockWithCheckpointHeaderValidatorSpec
}

it should "return when failure when checkpoint has too many signatures" in new TestSetup {
val invalidCheckpoint = validCheckpoint.copy(signatures = (validCheckpoint.signatures ++ validCheckpoint.signatures).sorted)
val invalidCheckpoint =
validCheckpoint.copy(signatures = (validCheckpoint.signatures ++ validCheckpoint.signatures).sorted)
val invalidBlockHeaderExtraFields = HefPostEcip1097(false, Some(invalidCheckpoint))
val invalidBlockHeader = validBlockHeaderWithCheckpoint.copy(extraFields = invalidBlockHeaderExtraFields)

Expand Down

0 comments on commit 90f7761

Please sign in to comment.