diff --git a/README.md b/README.md index d378c97..0bf281e 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,71 @@ Inspired by: This project is meant to learn and understand Bitcoin and Blockchain. I personally also in the process of learning. So, what's a better the approach of learning it by building one ! Because of this is a continuous learning process, there might be something I do not understand earlier. Now when I understand it, the code will also be changed according. I am happy to discuss with you, which will make this learning process quicker and efficient. +Start the service, run this Class: + +``` +com.fluency03.blockchain.api.Server +``` + +## REST APIs + REST API service is built on the open source projects [akka](https://github.com/akka/akka) and [akka-http](https://github.com/akka/akka-http). -API Documentation on Postman: [blockchain-in-scala](https://documenter.getpostman.com/view/1231202/blockchain-in-scala/RVu8iTUP) +Please see the full API Documentation on Postman: [blockchain-in-scala](https://documenter.getpostman.com/view/1231202/blockchain-in-scala/RVu8iTUP) -Start the service, run this Class: +Summary: + +### root ``` -com.fluency03.blockchain.api.Server +/ +``` + +### blockchain + + +``` + +``` + + +### block + +``` + +``` + + + +### transaction + +``` + +``` + + + + +### network + +``` + +``` + + + +### generic + ``` +``` + + + + + -#### Todos +## Todos - Complete APIs' Todos - API tests 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 34986cd..3890c5c 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/BlockPoolActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/BlockPoolActorTest.scala @@ -38,6 +38,12 @@ class BlockPoolActorTest extends TestKit(ActorSystem("BlocksActorTest")) with Im blockPoolActor ! GetBlocks(Set("somehash")) expectMsg(Seq.empty[Block]) + blockPoolActor ! GetTxOfBlock("aa", Block.genesisBlock.hash) + expectMsg(None) + + blockPoolActor ! GetTxOfBlock(Block.genesisBlock.transactions.head.id, "bb") + expectMsg(Some(Block.genesisBlock.transactions.head)) + blockPoolActor ! GetBlocks(Set(Block.genesisBlock.hash)) expectMsg(Seq(Block.genesisBlock)) 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 d4c4a79..b2571bb 100644 --- a/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala +++ b/src/test/scala/com/fluency03/blockchain/api/actors/BlockchainActorTest.scala @@ -49,6 +49,9 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi blockchainActor ! GetBlockFromChain(genesis.hash) expectMsg(Some(genesis)) + blockchainActor ! GetLastBlock + expectMsg(Some(genesis)) + blockchainActor ! GetTxOfBlock(genesis.transactions.head.id, genesis.hash) expectMsg(Some(genesis.transactions.head)) @@ -129,6 +132,12 @@ class BlockchainActorTest extends TestKit(ActorSystem("BlockchainActorTest")) wi actualBlock.previousHash shouldEqual genesis.hash } + blockchainActor ! RemoveLastBlock + expectMsg(SuccessMsg(s"Last Block ${genesis.hash} removed from the chain.")) + + blockchainActor ! GetLastBlock + expectMsg(None) + blockchainActor ! DeleteBlockchain expectMsg(SuccessMsg("Blockchain deleted."))