diff --git a/src/main/scala/com/fluency03/blockchain/api/actors/BlockPoolActor.scala b/src/main/scala/com/fluency03/blockchain/api/actors/BlockPoolActor.scala index 3cd717b..c6dfe51 100644 --- a/src/main/scala/com/fluency03/blockchain/api/actors/BlockPoolActor.scala +++ b/src/main/scala/com/fluency03/blockchain/api/actors/BlockPoolActor.scala @@ -10,9 +10,10 @@ import scala.collection.mutable object BlockPoolActor { final case object GetBlocks final case class GetBlocks(hashes: Set[String]) - final case class CreateBlock(block: Block) + final case class AddBlock(block: Block) final case class GetBlock(hash: String) final case class DeleteBlock(hash: String) + final case class GetTxOfBlock(id: String, hash: String) def props: Props = Props[BlockPoolActor] } @@ -31,19 +32,17 @@ class BlockPoolActor extends ActorSupport { def receive: Receive = { case GetBlocks => onGetBlocks() case GetBlocks(hashes) => onGetBlocks(hashes) - case CreateBlock(block) => onCreateBlock(block) + case AddBlock(block) => onAddBlock(block) case GetBlock(hash) => onGetBlock(hash) case DeleteBlock(hash) => onDeleteBlock(hash) + case GetTxOfBlock(id, hash) => onGetTxOfBlock(id, hash) case _ => unhandled _ } /** * TODO (Chang): new APIS: * - CreateBlock - * - GetBlock (onChain or offChain) - * - GetTransactionOfABlock * - ContainsBlock - * - AddBlockOnChain * */ @@ -53,7 +52,7 @@ class BlockPoolActor extends ActorSupport { k => hashes.contains(k) ).values.toSeq - private[this] def onCreateBlock(block: Block): Unit = { + private[this] def onAddBlock(block: Block): Unit = { if (blocksPool.contains(block.hash)) sender() ! FailureMsg(s"Block ${block.hash} already exists in the Pool.") else { blocksPool += (block.hash -> block) @@ -69,4 +68,9 @@ class BlockPoolActor extends ActorSupport { sender() ! SuccessMsg(s"Block $hash deleted from the Pool.") } else sender() ! FailureMsg(s"Block $hash does not exist in the Pool.") + private def onGetTxOfBlock(id: String, hash: String): Unit = blocksPool.get(hash) match { + case Some(block) => sender() ! block.transactions.find(_.id == id) + case None => sender() ! None + } + } diff --git a/src/main/scala/com/fluency03/blockchain/api/actors/BlockchainActor.scala b/src/main/scala/com/fluency03/blockchain/api/actors/BlockchainActor.scala index 12efb56..b0dbbae 100644 --- a/src/main/scala/com/fluency03/blockchain/api/actors/BlockchainActor.scala +++ b/src/main/scala/com/fluency03/blockchain/api/actors/BlockchainActor.scala @@ -15,10 +15,11 @@ object BlockchainActor { final case object CreateBlockchain final case object DeleteBlockchain final case class GetBlockFromChain(hash: String) + final case object GetLastBlock final case class GetTxOfBlock(id: String, hash: String) - final case class AddBlock(block: Block) - final case class AddBlockFromPool(hash: String) - final case object RemoveBlock + final case class AppendBlock(block: Block) + final case class AppendBlockFromPool(hash: String) + final case object RemoveLastBlock final case class MineNextBlock(data: String, ids: Seq[String]) final case object CheckBlockchainValidity final case class GetBlockFromPool(hash: String) @@ -45,10 +46,11 @@ class BlockchainActor extends ActorSupport { case CreateBlockchain => onCreateBlockchain() case DeleteBlockchain => onDeleteBlockchain() case GetBlockFromChain(hash) => onGetBlockFromChain(hash) + case GetLastBlock => onGetLastBlock() case GetTxOfBlock(id, hash) => onGetTxOfBlock(id, hash) - case AddBlock(block) => onAddBlock(block) - case AddBlockFromPool(hash) => onAddBlockFromPool(hash) - case RemoveBlock => onRemoveBlock() + case AppendBlock(block) => onAppendBlock(block) + case AppendBlockFromPool(hash) => onAppendBlockFromPool(hash) + case RemoveLastBlock => onRemoveLastBlock() case MineNextBlock(data, ids) => onMineNextBlock(data, ids) case CheckBlockchainValidity => onCheckBlockchainValidity() case GetBlockFromPool(hash) => onGetBlockFromPool(hash) @@ -57,6 +59,7 @@ class BlockchainActor extends ActorSupport { /** * TODO (Chang): + * - GetLastBlock * */ @@ -83,12 +86,20 @@ class BlockchainActor extends ActorSupport { private def onGetBlockFromChain(hash: String): Unit = sender() ! getBlockFromChain(hash) + private def onGetLastBlock(): Unit = blockchainOpt match { + case Some(blockchain) => sender() ! blockchain.lastBlock() + case None => + log.error("Blockchain does not exist! Clear the hash-to-index mapping!") + hashIndexMapping.clear() + None + } + private def onGetTxOfBlock(id: String, hash: String): Unit = getBlockFromChain(hash) match { case Some(block) => sender() ! block.transactions.find(_.id == id) case None => sender() ! None } - private def onAddBlock(block: Block): Unit = blockchainOpt match { + private def onAppendBlock(block: Block): Unit = blockchainOpt match { case Some(blockchain) => blockchainOpt = Some(blockchain.addBlock(block)) hashIndexMapping += (block.hash -> blockchain.length) @@ -99,7 +110,7 @@ class BlockchainActor extends ActorSupport { sender() ! FailureMsg("Blockchain does not exist.") } - private def onAddBlockFromPool(hash: String): Unit = blockchainOpt match { + private def onAppendBlockFromPool(hash: String): Unit = blockchainOpt match { case Some(blockchain) => val maybeBlock: Future[Option[Block]] = (blockPoolActor ? BlockPoolActor.GetBlock(hash)).mapTo[Option[Block]] val theSender: ActorRef = sender() @@ -120,7 +131,7 @@ class BlockchainActor extends ActorSupport { sender() ! FailureMsg("Blockchain does not exist.") } - private def onRemoveBlock(): Unit = blockchainOpt match { + private def onRemoveLastBlock(): Unit = blockchainOpt match { case Some(blockchain) => val toBeRemoved = blockchain.chain.head blockchainOpt = Some(blockchain.removeBlock()) diff --git a/src/main/scala/com/fluency03/blockchain/api/actors/TxPoolActor.scala b/src/main/scala/com/fluency03/blockchain/api/actors/TxPoolActor.scala index 2a4dc74..c922a51 100644 --- a/src/main/scala/com/fluency03/blockchain/api/actors/TxPoolActor.scala +++ b/src/main/scala/com/fluency03/blockchain/api/actors/TxPoolActor.scala @@ -11,7 +11,7 @@ import scala.collection.mutable object TxPoolActor { final case object GetTransactions final case class GetTransactions(ids: Seq[String]) - final case class CreateTransaction(tx: Transaction) + final case class AddTransaction(tx: Transaction) final case class GetTransaction(id: String) final case class DeleteTransaction(id: String) final case class UpdateTransaction(tx: Transaction) @@ -39,7 +39,7 @@ class TxPoolActor extends ActorSupport { def receive: Receive = { case GetTransactions => onGetTransactions() case GetTransactions(ids) => onGetTransactions(ids) - case CreateTransaction(tx) => onCreateTransaction(tx) + case AddTransaction(tx) => onAddTransaction(tx) case GetTransaction(id) => onGetTransaction(id) case DeleteTransaction(id) => onDeleteTransaction(id) case UpdateTransaction(tx) => onUpdateTransaction(tx) @@ -51,7 +51,7 @@ class TxPoolActor extends ActorSupport { private def onGetTransactions(ids: Seq[String]): Unit = sender() ! ids.map(id => transPool.get(id)).filter(_.isDefined).map(_.get) - private def onCreateTransaction(tx: Transaction): Unit = + private def onAddTransaction(tx: Transaction): Unit = if (transPool.contains(tx.id)) sender() ! FailureMsg(s"Transaction ${tx.id} already exists in the Pool.") else { transPool += (tx.id -> tx) diff --git a/src/main/scala/com/fluency03/blockchain/api/package.scala b/src/main/scala/com/fluency03/blockchain/api/package.scala index a0544d1..0ed440c 100644 --- a/src/main/scala/com/fluency03/blockchain/api/package.scala +++ b/src/main/scala/com/fluency03/blockchain/api/package.scala @@ -17,4 +17,10 @@ package object api { val PARENT_UP = "../" + + + + + + } diff --git a/src/main/scala/com/fluency03/blockchain/api/routes/BlockPoolRoutes.scala b/src/main/scala/com/fluency03/blockchain/api/routes/BlockPoolRoutes.scala index c5e9d4b..9c7ed3b 100644 --- a/src/main/scala/com/fluency03/blockchain/api/routes/BlockPoolRoutes.scala +++ b/src/main/scala/com/fluency03/blockchain/api/routes/BlockPoolRoutes.scala @@ -11,7 +11,7 @@ import akka.http.scaladsl.unmarshalling.PredefinedFromStringUnmarshallers.CsvSeq import akka.pattern.ask import com.fluency03.blockchain.api.{Blocks, Message} import com.fluency03.blockchain.api.actors.BlockPoolActor._ -import com.fluency03.blockchain.core.Block +import com.fluency03.blockchain.core.{Block, Transaction} import scala.concurrent.Future @@ -23,16 +23,14 @@ trait BlockPoolRoutes extends RoutesSupport { /** * TODO (Chang): new APIS: * - CreateBlock - * - GetBlock (onChain or offChain) * - GetTransactionOfABlock * - ContainsBlock - * - AddBlockOnChain * */ lazy val blockPoolRoutes: Route = path(BLOCKS) { - parameters( 'hashes.as(CsvSeq[String]).? ) { hashesOpt => + parameters( 'hashes.as(CsvSeq[String]).? ) { hashesOpt: Option[Seq[String]] => val blocks: Future[Blocks] = hashesOpt match { case Some(hashes) => (blockPoolActor ? GetBlocks(hashes.toSet)).mapTo[Blocks] case None => (blockPoolActor ? GetBlocks).mapTo[Blocks] @@ -44,19 +42,27 @@ trait BlockPoolRoutes extends RoutesSupport { pathEnd { post { entity(as[Block]) { block => - val blockCreated: Future[Message] = (blockPoolActor ? CreateBlock(block)).mapTo[Message] + val blockCreated: Future[Message] = (blockPoolActor ? AddBlock(block)).mapTo[Message] onSuccess(blockCreated) { respondOnCreation } } } } ~ - path(Segment) { hash => - get { - val maybeBlock: Future[Option[Block]] = (blockPoolActor ? GetBlock(hash)).mapTo[Option[Block]] - rejectEmptyResponse { complete(maybeBlock) } + pathPrefix(Segment) { hash => + pathEnd { + get { + val maybeBlock: Future[Option[Block]] = (blockPoolActor ? GetBlock(hash)).mapTo[Option[Block]] + rejectEmptyResponse { complete(maybeBlock) } + } ~ + delete { + val blockDeleted: Future[Message] = (blockPoolActor ? DeleteBlock(hash)).mapTo[Message] + onSuccess(blockDeleted) { respondOnDeletion } + } } ~ - delete { - val blockDeleted: Future[Message] = (blockPoolActor ? DeleteBlock(hash)).mapTo[Message] - onSuccess(blockDeleted) { respondOnDeletion } + path(TRANSACTION / Segment) { id => + get { + val maybeTx: Future[Option[Transaction]] = (blockPoolActor ? GetTxOfBlock(id, hash)).mapTo[Option[Transaction]] + rejectEmptyResponse { complete(maybeTx) } + } } } } diff --git a/src/main/scala/com/fluency03/blockchain/api/routes/BlockchainRoutes.scala b/src/main/scala/com/fluency03/blockchain/api/routes/BlockchainRoutes.scala index 80947c0..4d505f5 100644 --- a/src/main/scala/com/fluency03/blockchain/api/routes/BlockchainRoutes.scala +++ b/src/main/scala/com/fluency03/blockchain/api/routes/BlockchainRoutes.scala @@ -33,6 +33,38 @@ trait BlockchainRoutes extends RoutesSupport { onSuccess(validity) { respondOnUpdate } } } ~ + path(LAST_BLOCK) { + get { + val maybeLastBlock: Future[Option[Block]] = (blockchainActor ? GetLastBlock).mapTo[Option[Block]] + rejectEmptyResponse { complete(maybeLastBlock) } + } ~ + delete { + val blockchainUpdated: Future[Message] = (blockchainActor ? RemoveLastBlock).mapTo[Message] + onSuccess(blockchainUpdated) { respondOnUpdate } + } + } ~ + path(NEW_BLOCK) { + parameters('hash.?) { + case Some(hash) => + val blockchainUpdated: Future[Message] = (blockchainActor ? AppendBlockFromPool(hash)).mapTo[Message] + onSuccess(blockchainUpdated) { respondOnUpdate } + case None => entity(as[Block]) { block => + val blockchainUpdated: Future[Message] = (blockchainActor ? AppendBlock(block)).mapTo[Message] + onSuccess(blockchainUpdated) { respondOnUpdate } + } + } + } ~ + path(NEXT_BLOCK) { + post { + parameters('id.as(CsvSeq[String]).?) { idsOpt: Option[Seq[String]] => + entity(as[Input]) { in => + val maybeNextBlock: Future[Option[Block]] = + (blockchainActor ? MineNextBlock(in.content, idsOpt.getOrElse(Seq.empty[String]))).mapTo[Option[Block]] + rejectEmptyResponse { complete(maybeNextBlock) } + } + } + } + } ~ pathEnd { get { val blockchain: Future[Option[Blockchain]] = (blockchainActor ? GetBlockchain).mapTo[Option[Blockchain]] @@ -42,30 +74,6 @@ trait BlockchainRoutes extends RoutesSupport { val blockchainCreated: Future[Message] = (blockchainActor ? CreateBlockchain).mapTo[Message] onSuccess(blockchainCreated) { respondOnCreation } } ~ - put { - parameters('action, 'hash.?, 'id.as(CsvSeq[String]).?) { - (action, hashOpt: Option[String], idsOpt: Option[Seq[String]]) => action match { - case ADD_BLOCK_ACTION => hashOpt match { - case Some(hash) => - val blockchainUpdated: Future[Message] = (blockchainActor ? AddBlockFromPool(hash)).mapTo[Message] - onSuccess(blockchainUpdated) { respondOnUpdate } - case None => entity(as[Block]) { block => - val blockchainUpdated: Future[Message] = (blockchainActor ? AddBlock(block)).mapTo[Message] - onSuccess(blockchainUpdated) { respondOnUpdate } - } - } - case REMOVE_BLOCK_ACTION => - val blockchainUpdated: Future[Message] = (blockchainActor ? RemoveBlock).mapTo[Message] - onSuccess(blockchainUpdated) { respondOnUpdate } - case MINE_NEXT_BLOCK_ACTION => entity(as[Input]) { in => - val maybeNextBlock: Future[Option[Block]] = - (blockchainActor ? MineNextBlock(in.content, idsOpt.getOrElse(Seq.empty[String]))).mapTo[Option[Block]] - rejectEmptyResponse { complete(maybeNextBlock) } - } - case act => complete((StatusCodes.BadRequest, FailureMsg(s"Action Not Supported: $act"))) - } - } - } ~ delete { val blockchainDeleted: Future[Message] = (blockchainActor ? DeleteBlockchain).mapTo[Message] onSuccess(blockchainDeleted) { respondOnDeletion } @@ -80,7 +88,6 @@ trait BlockchainRoutes extends RoutesSupport { } ~ path(TRANSACTION / Segment) { id => get { - log.info(s"$id; $hash") val maybeTx: Future[Option[Transaction]] = (blockchainActor ? GetTxOfBlock(id, hash)).mapTo[Option[Transaction]] rejectEmptyResponse { complete(maybeTx) } } diff --git a/src/main/scala/com/fluency03/blockchain/api/routes/TxPoolRoutes.scala b/src/main/scala/com/fluency03/blockchain/api/routes/TxPoolRoutes.scala index 4ad9104..260894e 100644 --- a/src/main/scala/com/fluency03/blockchain/api/routes/TxPoolRoutes.scala +++ b/src/main/scala/com/fluency03/blockchain/api/routes/TxPoolRoutes.scala @@ -23,7 +23,6 @@ trait TxPoolRoutes extends RoutesSupport { /** * TODO (Chang): - * - Update transaction * - Sign transaction * */ @@ -42,7 +41,7 @@ trait TxPoolRoutes extends RoutesSupport { pathEnd { post { entity(as[Transaction]) { tx => - val msgOnCreate: Future[Message] = (txPoolActor ? CreateTransaction(tx)).mapTo[Message] + val msgOnCreate: Future[Message] = (txPoolActor ? AddTransaction(tx)).mapTo[Message] onSuccess(msgOnCreate) { respondOnCreation } } } diff --git a/src/main/scala/com/fluency03/blockchain/api/routes/package.scala b/src/main/scala/com/fluency03/blockchain/api/routes/package.scala index 2d87977..78d1c84 100644 --- a/src/main/scala/com/fluency03/blockchain/api/routes/package.scala +++ b/src/main/scala/com/fluency03/blockchain/api/routes/package.scala @@ -16,9 +16,9 @@ package object routes { // blockchain val BLOCKCHAIN = "blockchain" val VALIDITY = "validity" - val ADD_BLOCK_ACTION = "addBlock" - val REMOVE_BLOCK_ACTION = "removeBlock" - val MINE_NEXT_BLOCK_ACTION = "mineNextBlock" + val LAST_BLOCK = "last-block" + val NEW_BLOCK = "new-block" + val NEXT_BLOCK = "next-block" // block val BLOCKS = "blocks" diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/BlockPoolActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/BlockPoolActorTest.scala index 1b7e088..34986cd 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/BlockPoolActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/BlockPoolActorTest.scala @@ -26,10 +26,10 @@ class BlockPoolActorTest extends TestKit(ActorSystem("BlocksActorTest")) with Im blockPoolActor ! GetBlocks(Set("somehash")) expectMsg(Seq.empty[Block]) - blockPoolActor ! CreateBlock(Block.genesisBlock) + blockPoolActor ! AddBlock(Block.genesisBlock) expectMsg(SuccessMsg(s"Block ${Block.genesisBlock.hash} created in the Pool.")) - blockPoolActor ! CreateBlock(Block.genesisBlock) + blockPoolActor ! AddBlock(Block.genesisBlock) expectMsg(FailureMsg(s"Block ${Block.genesisBlock.hash} already exists in the Pool.")) blockPoolActor ! GetBlocks diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala index 21b7c3b..d4c4a79 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala @@ -2,10 +2,10 @@ package com.fluency03.blockchain.api.actors import akka.actor.{ActorRef, ActorSystem, Props} import akka.testkit.{DefaultTimeout, ImplicitSender, TestKit} -import com.fluency03.blockchain.api.actors.BlockPoolActor.CreateBlock +import com.fluency03.blockchain.api.actors.BlockPoolActor.AddBlock import com.fluency03.blockchain.api.actors.BlockchainActor._ import com.fluency03.blockchain.api._ -import com.fluency03.blockchain.api.actors.TxPoolActor.CreateTransaction +import com.fluency03.blockchain.api.actors.TxPoolActor.AddTransaction import com.fluency03.blockchain.core.Transaction.createCoinbaseTx import com.fluency03.blockchain.core.{Block, Blockchain, Transaction} import com.fluency03.blockchain.{genesisMiner, genesisTimestamp} @@ -61,19 +61,19 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi blockchainActor ! CheckBlockchainValidity expectMsg(SuccessMsg("true")) - blockchainActor ! AddBlock(genesis) + blockchainActor ! AppendBlock(genesis) expectMsg(SuccessMsg(s"New Block ${genesis.hash} added on the chain.")) blockchainActor ! CheckBlockchainValidity expectMsg(SuccessMsg("false")) - blockchainActor ! RemoveBlock + blockchainActor ! RemoveLastBlock expectMsg(SuccessMsg(s"Last Block ${genesis.hash} removed from the chain.")) blockchainActor ! CheckBlockchainValidity expectMsg(SuccessMsg("true")) - blockPoolActor ! CreateBlock(genesis) + blockPoolActor ! AddBlock(genesis) expectMsg(SuccessMsg(s"Block ${genesis.hash} created in the Pool.")) within(15 seconds) { @@ -85,14 +85,14 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi } within(15 seconds) { - blockchainActor ! AddBlockFromPool(genesis.hash) + blockchainActor ! AppendBlockFromPool(genesis.hash) expectMsg(SuccessMsg(s"New Block ${genesis.hash} added on the chain.")) - blockchainActor ! AddBlockFromPool("someid") + blockchainActor ! AppendBlockFromPool("someid") expectMsg(FailureMsg(s"Did not find Block someid in the poll.")) } - blockchainActor ! RemoveBlock + blockchainActor ! RemoveLastBlock expectMsg(SuccessMsg(s"Last Block ${genesis.hash} removed from the chain.")) within(15 seconds) { @@ -109,13 +109,13 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi val tx1: Transaction = createCoinbaseTx(1, genesisMiner, genesisTimestamp) val tx2: Transaction = createCoinbaseTx(2, genesisMiner, genesisTimestamp) val tx3: Transaction = createCoinbaseTx(3, genesisMiner, genesisTimestamp) - txPoolActor ! CreateTransaction(tx1) + txPoolActor ! AddTransaction(tx1) expectMsg(SuccessMsg(s"Transaction ${tx1.id} created in the Pool.")) - txPoolActor ! CreateTransaction(tx2) + txPoolActor ! AddTransaction(tx2) expectMsg(SuccessMsg(s"Transaction ${tx2.id} created in the Pool.")) - txPoolActor ! CreateTransaction(tx3) + txPoolActor ! AddTransaction(tx3) expectMsg(SuccessMsg(s"Transaction ${tx3.id} created in the Pool.")) within(15 seconds) { @@ -135,13 +135,13 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi blockchainActor ! DeleteBlockchain expectMsg(FailureMsg("Blockchain does not exist.")) - blockchainActor ! AddBlock(genesis) + blockchainActor ! AppendBlock(genesis) expectMsg(FailureMsg("Blockchain does not exist.")) - blockchainActor ! AddBlockFromPool(genesis.hash) + blockchainActor ! AppendBlockFromPool(genesis.hash) expectMsg(FailureMsg("Blockchain does not exist.")) - blockchainActor ! RemoveBlock + blockchainActor ! RemoveLastBlock expectMsg(FailureMsg("Blockchain does not exist.")) blockchainActor ! CheckBlockchainValidity diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/TxPoolActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/TxPoolActorTest.scala index 34cb7fa..00aceed 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/TxPoolActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/TxPoolActorTest.scala @@ -29,10 +29,10 @@ class TxPoolActorTest extends TestKit(ActorSystem("TransactionsActorTest")) with expectMsg(Seq.empty[Transaction]) val genesisTx: Transaction = createCoinbaseTx(0, genesisMiner, genesisTimestamp) - txPoolActor ! CreateTransaction(genesisTx) + txPoolActor ! AddTransaction(genesisTx) expectMsg(SuccessMsg(s"Transaction ${genesisTx.id} created in the Pool.")) - txPoolActor ! CreateTransaction(genesisTx) + txPoolActor ! AddTransaction(genesisTx) expectMsg(FailureMsg(s"Transaction ${genesisTx.id} already exists in the Pool.")) txPoolActor ! GetTransactions @@ -41,10 +41,10 @@ class TxPoolActorTest extends TestKit(ActorSystem("TransactionsActorTest")) with val tx2: Transaction = createCoinbaseTx(2, genesisMiner, genesisTimestamp) val tx3: Transaction = createCoinbaseTx(3, genesisMiner, genesisTimestamp) - txPoolActor ! CreateTransaction(tx2) + txPoolActor ! AddTransaction(tx2) expectMsg(SuccessMsg(s"Transaction ${tx2.id} created in the Pool.")) - txPoolActor ! CreateTransaction(tx3) + txPoolActor ! AddTransaction(tx3) expectMsg(SuccessMsg(s"Transaction ${tx3.id} created in the Pool.")) txPoolActor ! GetTransactions(Seq("someid"))