From a0017d0311130ceda069dcc174af0ca8067f7099 Mon Sep 17 00:00:00 2001 From: fluency03 Date: Sat, 5 May 2018 18:49:11 +0200 Subject: [PATCH] add test for MineAndAddNextBlock --- .../blockchain/api/actors/BlockPoolActorTest.scala | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/scala/com/github/fluency03/blockchain/api/actors/BlockPoolActorTest.scala b/src/test/scala/com/github/fluency03/blockchain/api/actors/BlockPoolActorTest.scala index 835a5a1..b76b25f 100644 --- a/src/test/scala/com/github/fluency03/blockchain/api/actors/BlockPoolActorTest.scala +++ b/src/test/scala/com/github/fluency03/blockchain/api/actors/BlockPoolActorTest.scala @@ -4,7 +4,7 @@ import akka.actor.{ActorRef, ActorSystem, Props} import akka.testkit.{DefaultTimeout, ImplicitSender, TestKit} import com.github.fluency03.blockchain.api._ import com.github.fluency03.blockchain.api.actors.BlockPoolActor._ -import com.github.fluency03.blockchain.api.actors.BlockchainActor.CreateBlockchain +import com.github.fluency03.blockchain.api.actors.BlockchainActor.{CreateBlockchain, DeleteBlockchain} import com.github.fluency03.blockchain.core.{Block, Transaction} import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} @@ -58,7 +58,6 @@ class BlockPoolActorTest extends TestKit(ActorSystem("BlocksActorTest")) with De blockPoolActor ! GetBlock(Block.genesisBlock.hash) expectMsg(Some(Block.genesisBlock)) - within(15 seconds) { blockchainActor ! CreateBlockchain expectMsgType[SuccessMsg] @@ -80,6 +79,16 @@ class BlockPoolActorTest extends TestKit(ActorSystem("BlocksActorTest")) with De blocks.length shouldEqual 2 blocks should contain allOf (Block.genesisBlock, actualBlock) + within(15 seconds) { + blockchainActor ! DeleteBlockchain + expectMsg(SuccessMsg("Blockchain deleted.")) + } + + within(15 seconds) { + blockPoolActor ! MineAndAddNextBlock("next", Seq.empty[String]) + expectMsg(None) + } + blockPoolActor ! DeleteBlock(Block.genesisBlock.hash) expectMsg(SuccessMsg(s"Block ${Block.genesisBlock.hash} deleted from the Pool."))