diff --git a/src/main/scala/com/fluency03/blockchain/api/actors/PeerActor.scala b/src/main/scala/com/fluency03/blockchain/api/actors/PeerActor.scala index 37890b2..e24a029 100644 --- a/src/main/scala/com/fluency03/blockchain/api/actors/PeerActor.scala +++ b/src/main/scala/com/fluency03/blockchain/api/actors/PeerActor.scala @@ -18,7 +18,6 @@ class PeerActor extends ActorSupport { override def preStart(): Unit = log.info("{} started!", this.getClass.getSimpleName) override def postStop(): Unit = log.info("{} stopped!", this.getClass.getSimpleName) - // TODO (Chang): need persistence val wallets = mutable.Map.empty[String, KeyPair] wallets += { 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 e10a5a0..7dacceb 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala @@ -10,7 +10,7 @@ import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} import scala.concurrent.duration._ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) with DefaultTimeout with ImplicitSender - with WordSpecLike with Matchers with BeforeAndAfterAll { + with WordSpecLike with Matchers with BeforeAndAfterAll { override def afterAll: Unit = { shutdown() @@ -20,6 +20,8 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi "A BlockchainActor" should { "Respond with a Blockchain." in { + BlockchainActor.props shouldEqual Props[BlockchainActor] + blockchainActor ! GetBlockchain expectMsg(None) diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/BlocksActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/BlocksActorTest.scala index f3f4e55..958751c 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/BlocksActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/BlocksActorTest.scala @@ -18,6 +18,8 @@ class BlocksActorTest extends TestKit(ActorSystem("BlocksActorTest")) with Impli "A BlocksActor" should { "Respond with a Seq of Blocks." in { + BlocksActor.props shouldEqual Props[BlocksActor] + blocksActor ! GetBlocks expectMsg(Seq.empty[Block]) diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/NetworkActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/NetworkActorTest.scala index 51250b1..fddb9ef 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/NetworkActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/NetworkActorTest.scala @@ -1,5 +1,21 @@ package com.fluency03.blockchain.api.actors -class NetworkActorTest { +import akka.actor.{ActorRef, ActorSystem, Props} +import akka.testkit.{ImplicitSender, TestKit} +import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} + +class NetworkActorTest extends TestKit(ActorSystem("NetworkActorTest")) with ImplicitSender + with WordSpecLike with Matchers with BeforeAndAfterAll { + + override def afterAll: Unit = { + shutdown() + } + + val networkActor: ActorRef = system.actorOf(Props[NetworkActor]) + + + + + } diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/PeerActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/PeerActorTest.scala index 9f6850b..e176005 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/PeerActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/PeerActorTest.scala @@ -1,5 +1,30 @@ package com.fluency03.blockchain.api.actors -class PeerActorTest { +import akka.actor.{ActorRef, ActorSystem, Props} +import akka.testkit.{ImplicitSender, TestKit} +import com.fluency03.blockchain.api.actors.PeerActor.GetPublicKeys +import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} + +class PeerActorTest extends TestKit(ActorSystem("PeerActorTest")) with ImplicitSender + with WordSpecLike with Matchers with BeforeAndAfterAll { + + override def afterAll: Unit = { + shutdown() + } + + val peerActor: ActorRef = system.actorOf(Props[PeerActor]) + + "A BlocksActor" should { + "Respond with a Seq of Blocks." in { + PeerActor.props shouldEqual Props[PeerActor] + + peerActor ! GetPublicKeys + val publicKeys = expectMsgType[Set[String]] + publicKeys.size shouldEqual 1 + + peerActor ! "other" + expectNoMessage + } + } } diff --git a/src/test/scala/com/fluency03/blockchain/api/actors/TransactionsActorTest.scala b/src/test/scala/com/fluency03/blockchain/api/actors/TransactionsActorTest.scala index abe4430..5bc716d 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/TransactionsActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/TransactionsActorTest.scala @@ -10,7 +10,7 @@ import com.fluency03.blockchain.{genesisMiner, genesisTimestamp} import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} class TransactionsActorTest extends TestKit(ActorSystem("TransactionsActorTest")) with ImplicitSender - with WordSpecLike with Matchers with BeforeAndAfterAll { + with WordSpecLike with Matchers with BeforeAndAfterAll { override def afterAll: Unit = { shutdown() @@ -20,6 +20,8 @@ class TransactionsActorTest extends TestKit(ActorSystem("TransactionsActorTest") "A TransactionsActor" should { "Respond with a Seq of Transactions." in { + TransactionsActor.props shouldEqual Props[TransactionsActor] + transActor ! GetTransactions expectMsg(Seq.empty[Transaction])