Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fluency03 committed May 4, 2018
1 parent 5ae6051 commit f22c5de
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
61 changes: 57 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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."))

Expand Down

0 comments on commit f22c5de

Please sign in to comment.